|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface Stopwatch
Stopwatch Simon measures time spans and holds related statistics.
Methods start() creates new Split object.
On this object you can call Split.stop() - this demarcates measured interval.
Alternatively method addTime(long) can be used to add split time to the stopwatch. Both ways effectively
updates usage times, increase usage counter by one and updates total time of the stopwatch.
Split object enables multiple time-splits to be measured in parallel.
Split split = SimonManager.getStopwatch("com.my.stopwatch").start();
//... here goes the measured code
split.stop();
System.out.println("Result: " + split.getStopwatch()); // print will be probably somewhere else
This can be used for simple micro-benchmarking, critical section monitoring, in web
filter to measure request times, etc.
SimonManager should always be used to get the stopwatch before using it,
because otherwise the code will not reflect enable/disable of the whole API.
| Method Summary | |
|---|---|
Stopwatch |
addSplit(Split split)
Adds Split to the stopwatch which is useful for aggregation of splits created for other stopwatch. |
Stopwatch |
addTime(long ns)
Adds split time in nanoseconds to total time of the stopwatch. |
long |
getActive()
Returns current number of measured splits (concurrently running). |
long |
getCounter()
Returns usage count of the stopwatch. |
long |
getLast()
Returns value of the last added split - wheter it was added directly or with stop method. |
long |
getMax()
Returns maximal time split value in nanoseconds. |
long |
getMaxActive()
Returns peek value of active concurrent splits. |
long |
getMaxActiveTimestamp()
Retruns ms timestamp when the last peek of the active split count occured. |
long |
getMaxTimestamp()
Returns ms timestamp when the max value was measured. |
double |
getMean()
Returns mean value (average) of all measured values. |
long |
getMin()
Returns minimal time split value in nanoseconds. |
long |
getMinTimestamp()
Returns ms timestamp when the min value was measured. |
double |
getStandardDeviation()
Returns standard deviation for all measured values. |
long |
getTotal()
Returns total sum of all split times in nanoseconds. |
double |
getVariance()
Returns unbiased estimate of the population variance. |
double |
getVarianceN()
Returns variance value of all measured values (entire population). |
Stopwatch |
reset()
Resets the Simon - clears total time, min, max, usage stats, etc. |
StopwatchSample |
sample()
Samples Simon values and returns them in a Java Bean derived from Sample interface. |
StopwatchSample |
sampleAndReset()
Samples Simon values and returns them in a Java Bean derived from Sample interface and resets the Simon. |
Split |
start()
Starts the new split for this stopwatch. |
| Methods inherited from interface org.javasimon.Simon |
|---|
getFirstUsage, getChildren, getLastReset, getLastUsage, getName, getNote, getParent, getState, isEnabled, setNote, setState |
| Methods inherited from interface org.javasimon.HasAttributes |
|---|
getAttribute, getAttribute, getAttributeNames, getCopyAsSortedMap, removeAttribute, setAttribute |
| Method Detail |
|---|
Split start()
Split object is collected, no leak occurs. However, active count is increased
and without stopping the split active count stays increased which may render that
information useless.
Split.stop()Stopwatch addTime(long ns)
ns - split time
Stopwatch addSplit(Split split)
Split to the stopwatch which is useful for aggregation of splits created for other stopwatch.
Split object should be stopped. Main difference is the callback method called as
Callback.onStopwatchAdd(Stopwatch, Split, StopwatchSample) provides split object to the callback.
Usage examples:
Split split = Split.start(); // no stopwatch needed ... someStopwatch.addSplit(split.stop()); // you may omit stop(), if you does not use the split after this point
split - split object (should be stopped)
long getTotal()
long getLast()
long getCounter()
addTime and
stop - that means that it's updated every time the next time split is added.
long getMax()
long getMin()
long getMaxTimestamp()
long getMinTimestamp()
Stopwatch reset()
reset in interface Simonlong getActive()
long getMaxActive()
long getMaxActiveTimestamp()
double getMean()
double getStandardDeviation()
double getVariance()
double getVarianceN()
StopwatchSample sample()
Simon
sample in interface SimonStopwatchSample sampleAndReset()
Simon
sampleAndReset in interface Simon
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||