@NotThreadSafe public class Stopwatch extends Object implements Comparable<Stopwatch>
Constructor and Description |
---|
Stopwatch() |
Stopwatch(boolean detailedStats) |
Stopwatch(boolean detailedStats,
String description) |
Modifier and Type | Method and Description |
---|---|
int |
compareTo(Stopwatch that) |
Duration |
getAverageDuration()
Get the average duration that this stopwatch has recorded.
|
int |
getCount()
Return the number of runs (complete starts and stops) this stopwatch has undergone.
|
String |
getDescription() |
DetailedStatistics<Duration> |
getDetailedStatistics()
Return this stopwatch's detailed statistics, if they are being kept.
|
Histogram<Duration> |
getHistogram(int numSigmas)
Return the histogram of this stopwatch's individual runs.
|
Duration |
getMaximumDuration()
Get the maximum duration that this stopwatch has recorded.
|
Duration |
getMedianDuration()
Get the median duration that this stopwatch has recorded.
|
Duration |
getMinimumDuration()
Get the minimum duration that this stopwatch has recorded.
|
SimpleStatistics<Duration> |
getSimpleStatistics()
Return this stopwatch's simple statistics.
|
Duration |
getTotalDuration()
Get the total duration that this stopwatch has recorded.
|
boolean |
isDetailedStatistics()
Return true if detailed statistics are being kept.
|
boolean |
isRunning()
Return whether this stopwatch is currently running.
|
void |
lap()
Record the statistics for the latest run, but keep the stopwatch going.
|
void |
reset()
Reset this stopwatch and clear all statistics.
|
void |
start()
Start the stopwatch and begin recording the statistics a new run.
|
void |
stop()
Stop the stopwatch and record the statistics for the latest run.
|
String |
toString() |
public Stopwatch()
public Stopwatch(boolean detailedStats)
public Stopwatch(boolean detailedStats, String description)
public String getDescription()
public void start()
running
isRunning()
public void stop()
running
isRunning()
public void lap()
running
isRunning()
public int getCount()
isRunning()
public boolean isRunning()
public Duration getTotalDuration()
reset
public Duration getAverageDuration()
reset
public Duration getMedianDuration()
reset
public Duration getMinimumDuration()
reset
public Duration getMaximumDuration()
reset
public SimpleStatistics<Duration> getSimpleStatistics()
getDetailedStatistics()
public DetailedStatistics<Duration> getDetailedStatistics()
getSimpleStatistics()
public boolean isDetailedStatistics()
detailed statistics
are being kept, or false if only
simple statistics
are being kept.public Histogram<Duration> getHistogram(int numSigmas)
Note: if only simple statistics
are being kept, the resulting histogram is always empty.
The second kind of histogram is more useful when most of the data that is clustered near one value. This histogram is
focused around the values that are up to 'numSigmas' above and below the median
, and all
values outside of this range are placed in the first and last bucket.
numSigmas
- the number of standard deviations from the median
, or 0 if the buckets of the
histogram should be evenly distributedpublic void reset()
public int compareTo(Stopwatch that)
compareTo
in interface Comparable<Stopwatch>
Copyright © 2008–2016 JBoss, a division of Red Hat. All rights reserved.