예제 #1
0
 @Benchmark
 public long systematicallyReadWrite() {
   long time = System.nanoTime();
   long kudos = player.getKudos();
   long points = player.getPoints();
   player.update(points + time, kudos + points);
   return player.getKudos();
 }
예제 #2
0
 @Benchmark
 public long readOnly() {
   long time = System.nanoTime();
   if (time % 2 == 0) {
     return player.getKudos();
   } else {
     return player.getPoints();
   }
 }
예제 #3
0
 @Benchmark
 public long randomlyReadWrite() {
   long time = System.nanoTime();
   if (time % 2 == 0) {
     return player.getPoints();
   } else {
     if (time % 9 == 0) {
       player.update(time, time + 1);
       return 0l;
     } else {
       return player.getKudos();
     }
   }
 }
예제 #4
0
 @Benchmark
 public void writeOnly() {
   long time = System.nanoTime();
   player.update(time + 1, time - 1);
 }