Class TPSCalculator


  • public class TPSCalculator
    extends java.lang.Object
    Utility for calculating TPS using nano time.

    Math: - Minecraft runs 20 ticks / second, 1 tick = 50ms - To return 20 ticks, 1 second is expected - If the call time is less than 1 second, the TPS is still 20, excess is not counted. - If the call time is more than 1 second, the TPS is below 20 - If 2 seconds, TPS is 10 - If 4 seconds, TPS is 5 - If 20 seconds, TPS is 1 - If more than 20 seconds, TPS is 0 for 20 seconds and then according to the other rules.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static long SECOND_NS  
    • Constructor Summary

      Constructors 
      Constructor Description
      TPSCalculator()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.Optional<java.lang.Double> pulse​(long time)
      Pulse the TPS clock.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • SECOND_NS

        public static final long SECOND_NS
    • Constructor Detail

      • TPSCalculator

        public TPSCalculator()
    • Method Detail

      • pulse

        public java.util.Optional<java.lang.Double> pulse​(long time)
        Pulse the TPS clock.
        Parameters:
        time - Current epoch ms
        Returns:
        Average TPS for the minute, or empty.