Package io.github.zhengzhengyiyi.util
Class PerformanceMonitor.Timer
java.lang.Object
io.github.zhengzhengyiyi.util.PerformanceMonitor.Timer
- All Implemented Interfaces:
AutoCloseable
- Enclosing class:
PerformanceMonitor
AutoCloseable timer that automatically records performance metrics when closed.
Usage with try-with-resources pattern is recommended.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Stops the timer and records the performance metrics.voidRecords an error for the current operation.
-
Constructor Details
-
Timer
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:
closein interfaceAutoCloseable
-
recordError
public void recordError()Records an error for the current operation. Should be called when the operation fails.
-