|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.javasimon.AbstractSimon
org.javasimon.StopwatchImpl
final class StopwatchImpl
Class implements Stopwatch interface - see there for how to use Stopwatch.
Stopwatch| Field Summary | |
|---|---|
private long |
active
|
private long |
counter
|
private long |
last
|
private long |
max
|
private long |
maxActive
|
private long |
maxActiveTimestamp
|
private long |
maxTimestamp
|
private double |
mean
|
private double |
mean2
|
private long |
min
|
private long |
minTimestamp
|
private long |
total
|
| Fields inherited from class org.javasimon.AbstractSimon |
|---|
enabled, firstUsage, lastUsage, manager |
| Constructor Summary | |
|---|---|
StopwatchImpl(String name,
Manager manager)
Constructs Stopwatch Simon with a specified name and for the specified manager. |
|
| Method Summary | |
|---|---|
private void |
activeStart()
|
private long |
addSplit(long split)
|
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. |
(package private) void |
stop(Split split,
long start,
long nowNanos,
String subSimon)
Protected method doing the stop work based on provided start nano-time. |
String |
toString()
Returns Simon basic information, total time, counter, max value and min value as a human readable string. |
private void |
updateUsages()
Updates usage statistics. |
private void |
updateUsages(long nowNanos)
Updates usage statistics without using System.currentTimeMillis() if client code already has
current nano timer value. |
| Methods inherited from class org.javasimon.AbstractSimon |
|---|
addChild, getAttribute, getAttribute, getAttributeNames, getCopyAsSortedMap, getFirstUsage, getChildren, getLastReset, getLastUsage, getName, getNote, getParent, getState, isEnabled, removeAttribute, replaceChild, resetCommon, sampleCommon, setAttribute, setNote, setParent, setState |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| 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 |
| Field Detail |
|---|
private long total
private long counter
private long active
private long max
private long maxTimestamp
private long maxActive
private long maxActiveTimestamp
private long min
private long minTimestamp
private long last
private double mean
private double mean2
| Constructor Detail |
|---|
StopwatchImpl(String name,
Manager manager)
name - Simon's namemanager - owning manager| Method Detail |
|---|
public Stopwatch addTime(long ns)
Stopwatch
addTime in interface Stopwatchns - split time
public Stopwatch addSplit(Split split)
StopwatchSplit 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
addSplit in interface Stopwatchsplit - split object (should be stopped)
public Split start()
StopwatchSplit 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.
start in interface StopwatchSplit.stop()
void stop(Split split,
long start,
long nowNanos,
String subSimon)
split - Split object that has been stoppedstart - start nano-time of the split @return split time in nsnowNanos - current nano timesubSimon - name of the sub-stopwatch (hierarchy delimiter is added automatically), may be nullprivate void activeStart()
public Stopwatch reset()
Stopwatch
reset in interface Simonreset in interface Stopwatchprivate long addSplit(long split)
public double getMean()
Stopwatch
getMean in interface Stopwatchpublic double getVarianceN()
Stopwatch
getVarianceN in interface Stopwatchpublic double getVariance()
Stopwatch
getVariance in interface Stopwatchpublic double getStandardDeviation()
Stopwatch
getStandardDeviation in interface Stopwatchpublic long getTotal()
Stopwatch
getTotal in interface Stopwatchpublic long getLast()
Stopwatch
getLast in interface Stopwatchpublic long getCounter()
StopwatchaddTime and
stop - that means that it's updated every time the next time split is added.
getCounter in interface Stopwatchpublic long getMax()
Stopwatch
getMax in interface Stopwatchpublic long getMin()
Stopwatch
getMin in interface Stopwatchpublic long getMaxTimestamp()
Stopwatch
getMaxTimestamp in interface Stopwatchpublic long getMinTimestamp()
Stopwatch
getMinTimestamp in interface Stopwatchpublic long getActive()
Stopwatch
getActive in interface Stopwatchpublic long getMaxActive()
Stopwatch
getMaxActive in interface Stopwatchpublic long getMaxActiveTimestamp()
Stopwatch
getMaxActiveTimestamp in interface Stopwatchpublic StopwatchSample sampleAndReset()
Simon
sampleAndReset in interface SimonsampleAndReset in interface Stopwatchpublic StopwatchSample sample()
Simon
sample in interface Simonsample in interface Stopwatchprivate void updateUsages(long nowNanos)
System.currentTimeMillis() if client code already has
current nano timer value.
nowNanos - current value of nano timerprivate void updateUsages()
updateUsages(long) instead.
public String toString()
toString in class AbstractSimonAbstractSimon.toString()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||