コード例 #1
0
 @Override
 public void run() {
   long time = System.currentTimeMillis();
   timings.add(time - lastTime);
   lastTime = time;
   if (timings.size() > MAX_MEASUREMENTS) {
     timings.removeAt(0);
   }
   final int size = timings.size();
   if (size > 20) {
     TLongIterator i = timings.iterator();
     int count = 0;
     long last20 = 0;
     long total = 0;
     while (i.hasNext()) {
       long next = i.next();
       if (count > size - 20) {
         last20 += next;
       }
       total += next;
       count++;
     }
     ticksPerSecond.set(1000F / (last20 / 20F));
     avgTicksPerSecond.set(1000F / (total / ((float) size)));
   }
 }
コード例 #2
0
 public float getAvgTPS() {
   return avgTicksPerSecond.get();
 }
コード例 #3
0
 public float getTPS() {
   return ticksPerSecond.get();
 }