Class TPSCalculator

java.lang.Object
com.djrapitops.plan.gathering.timed.TPSCalculator

public class TPSCalculator extends 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 Details

    • SECOND_NS

      public static final long SECOND_NS
  • Constructor Details

    • TPSCalculator

      public TPSCalculator()
  • Method Details

    • pulse

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