Class StatTimer


  • public class StatTimer
    extends java.lang.Object
    Abstraction above Stopwatch to support inlined starts (when something tries to start already started timer). This is required when an initialization sequence could change and some blocks become part of already measured scope (in this case, such a measure should be simply ignored, as timer already counts it).
    Since:
    25.02.2025
    • Constructor Summary

      Constructors 
      Constructor Description
      StatTimer​(com.google.common.base.Stopwatch stopwatch)
      Create timer.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      com.google.common.base.Stopwatch getStopwatch()  
      boolean isRunning()  
      StatTimer start()
      Start timer.
      void stop()
      Stop timer.
      • Methods inherited from class java.lang.Object

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

      • StatTimer

        public StatTimer​(com.google.common.base.Stopwatch stopwatch)
        Create timer.
        Parameters:
        stopwatch - watch
    • Method Detail

      • start

        public StatTimer start()
        Start timer. Timer could be started multiple times (inlined scopes), but it must be stopped accordingly.
        Returns:
        timer instance
      • stop

        public void stop()
        Stop timer. Could be called multiple times if inlined scopes.
        Throws:
        java.lang.IllegalStateException - if the timer already stopped
      • isRunning

        public boolean isRunning()
        Returns:
        true if the timer is running
      • getStopwatch

        public com.google.common.base.Stopwatch getStopwatch()
        Returns:
        underlying stopwatch