java.lang.Object
ru.vyarus.dropwizard.guice.module.context.stat.StatTimer

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

    • StatTimer

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

    • 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:
      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