@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)));
   }
 }
 public float getAvgTPS() {
   return avgTicksPerSecond.get();
 }
 public float getTPS() {
   return ticksPerSecond.get();
 }