public final class StatisticTimer extends Statistics<StatisticTimer>
Note that additional calls to start will have no affect until stop is called. Update & set methods will leave current statistics stopped/started state untouched, but they will add values including elapsed time if started.
An example:
get() => 0 milliseconds start() 1000 milliseconds elapsed get() => 1000 milliseconds 100 milliseconds elapsed get() => 1100 milliseconds stop() 1000 milliseconds elapsed get() => 1100 milliseconds
replaceWith
Modifier | Constructor and Description |
---|---|
protected |
StatisticTimer(java.lang.String name)
Creates a new instance of StatisticTimer.
|
Modifier and Type | Method and Description |
---|---|
protected void |
addBoundStat(StatisticTimer stat)
Bind a statistic to this statistic.
|
protected StatisticTimer |
cast()
Returns this statistics as the type provided typed argument.
|
long |
get()
Time elapsed in milliseconds.
|
long |
getCpuTime()
Total CPU time elapsed in milliseconds.
|
static StatisticTimer |
getStatistics(java.lang.String name)
Factory method for creating a new statistic timer with the specified name or get the one already existing.
|
long |
getUserTime()
User CPU time elapsed in milliseconds.
|
java.lang.Long |
getValue()
Returns the value of this statistic.
|
boolean |
changedSinceCheckpoint()
Test whether this statistics has been changed since the last checkpoint.
|
protected void |
removeBoundStat(StatisticTimer stat)
Remove a bound statistic from this one.
|
void |
reset()
Reset the value of this statistic.
|
protected void |
setFrom(StatisticTimer sourceStat)
Set the value of this statistic to the actual value of the given
sourceStat . |
void |
setCheckpoint()
Sets checkpoint.
|
static boolean |
setupCPUTime(boolean enable)
Initialization method for computing CPU times.
|
void |
start()
Starts incrementing the timer
|
void |
stop()
Stops incrementing timer
|
java.lang.String |
toString() |
protected void |
updateFrom(StatisticTimer sourceStat)
Updates the value of this statistic from the given
sourceStat . |
bindTo, canPerformOperation, disableGlobally, enableGlobally, getAllStatistics, getAllStatistics, getBoundStats, getBoundTo, getName, getStatistics, isBound, isEnabledGlobally, isRegisteredGlobally, printStatistics, printStatistics, printStatistics, readResolve, removeStatistic, resetStatistics, resetStatistics, unbind
protected StatisticTimer(java.lang.String name)
name
- the requested name of the statisticspublic static boolean setupCPUTime(boolean enable)
enable
- flag whether to enable (true) the CPU times or disable them (false)public void start()
public void stop()
public long get()
public long getCpuTime()
public long getUserTime()
public java.lang.Long getValue()
Statistics
getValue
in class Statistics<StatisticTimer>
protected void addBoundStat(StatisticTimer stat)
Statistics
stat
to receive notifications when
the value of this statistic is updated.addBoundStat
in class Statistics<StatisticTimer>
stat
- the statistic to registerprotected void removeBoundStat(StatisticTimer stat)
Statistics
removeBoundStat
in class Statistics<StatisticTimer>
stat
- the statistic to unbindprotected void updateFrom(StatisticTimer sourceStat)
Statistics
sourceStat
.
Specifically, this method merges the value of the sourceStat
with this statistic.
The actual implementation depends on the type of the statistic.
updateFrom
in class Statistics<StatisticTimer>
sourceStat
- the statistic from which to update this statprotected void setFrom(StatisticTimer sourceStat)
Statistics
sourceStat
.setFrom
in class Statistics<StatisticTimer>
sourceStat
- the statistic from which to set this statpublic void reset()
Statistics
reset
in class Statistics<StatisticTimer>
public static StatisticTimer getStatistics(java.lang.String name) throws java.lang.ClassCastException
name
- requested name of the statisticsStatisticTimer
having the passed name.java.lang.ClassCastException
- if the statistics of the given name exists, but is of a different class than StatisticTimer
public java.lang.String toString()
toString
in class java.lang.Object
public boolean changedSinceCheckpoint()
true
if it has been changed, otherwise false
.public void setCheckpoint()
protected StatisticTimer cast()
Statistics
cast
in class Statistics<StatisticTimer>