Package net.bull.javamelody
Class Stopwatch
java.lang.Object
net.bull.javamelody.Stopwatch
- All Implemented Interfaces:
AutoCloseable
Stopwatch to record execution times of a piece of code in the services statistics.
(To monitor whole methods, see MonitoringSpringInterceptor, MonitoringInterceptor or MonitoringProxy.)
- Author:
- Emeric Vernat
-
Constructor Details
-
Stopwatch
Starts a stopwatch (must always be used in try-with-resource):try (Stopwatch stopwatch = new Stopwatch("nameyouwant")) { // your code }- Parameters:
stopwatchName- Whatever name you want to display in the statistics
-
-
Method Details
-
getName
- Returns:
- name of the stopwatch.
-
getDuration
public long getDuration()- Returns:
- duration until now or until stop of the stopwatch.
-
isClosed
public boolean isClosed()- Returns:
- already stopped ?
-
close
public void close()Stops the stopwatch.- Specified by:
closein interfaceAutoCloseable
-