public class PerformanceClock
extends java.lang.Object
It is designed for simplicity and performance; you are responsible for thread safety and ensuring that starts and stops match properly.
Example of usage:
clock = SystemServices.performance().createClockFor("coffee drinking");
while (time < millerTime) {
clock.start();
drinkCoffee();
clock.stop();
}
clock.updateMeter();
Copyright 1998-2012 Partner Software, Inc.
| Constructor and Description |
|---|
PerformanceClock(PerformanceMeter meter) |
| Modifier and Type | Method and Description |
|---|---|
void |
cycle()
Bumps the cycle count; this is the same as a stop() followed by a start().
|
long |
getCycles()
Get the value of the counter.
|
double |
getHertz()
Get the cycles/sec.
|
long |
getMilliseconds()
Get the total time in milliseconds of all timing runs.
|
void |
reset()
Reset everything to zero.
|
void |
start()
Start the clock and begins a cycle.
|
void |
stop()
Stop the clock, ending the cycle and incrementing the cycle counter by one.
|
void |
stop(long cycles)
Stop the clock and increment the cycle counter by the given number of cycles.
|
void |
stopAndUpdateMeter()
Guess what this does? Three guesses only.
|
void |
updateMeter()
Send timing and counter data to this clock's meter.
|
public PerformanceClock(PerformanceMeter meter)
public void reset()
public void start()
public void stop()
public void stop(long cycles)
Use this if your start/stop combination encompasses multiple laps or runs or whatever you're timing.
public void updateMeter()
public void stopAndUpdateMeter()
public void cycle()
public long getMilliseconds()
public long getCycles()
public double getHertz()