Class PerformanceMonitor.Timer

java.lang.Object
io.github.zhengzhengyiyi.util.PerformanceMonitor.Timer
All Implemented Interfaces:
AutoCloseable
Enclosing class:
PerformanceMonitor

public static class PerformanceMonitor.Timer extends Object implements AutoCloseable
AutoCloseable timer that automatically records performance metrics when closed. Usage with try-with-resources pattern is recommended.
  • Constructor Details

    • Timer

      public Timer(String operationName)
      Creates a new timer for the specified operation.
      Parameters:
      operationName - the name of the operation to monitor
  • Method Details

    • close

      public void close()
      Stops the timer and records the performance metrics.
      Specified by:
      close in interface AutoCloseable
    • recordError

      public void recordError()
      Records an error for the current operation. Should be called when the operation fails.