public class Timer extends Object implements Serializable
Constructor and Description |
---|
Timer()
Default Constructor which saves the current time
as epochMillis and epochNanos (the start of the benchmark).
|
Modifier and Type | Method and Description |
---|---|
void |
adjustBaseTime(int offset)
Adjusts the base time based on the clock differences of this JVM to
the master's JVM.
|
void |
calibrate(String id,
long startRamp,
long endRamp)
Runs a timer sleep time calibration for a certain amount of time.
|
long |
getCompensation()
Reads the compensation value.
|
double |
getDeviation()
Reads the deviation value.
|
int |
getTime()
Obtains the current time relative to the base time, in
milliseconds.
|
void |
idleTimerCheck(String id) |
long |
toAbsMillis(int relTimeMillis)
Converts the millisec time relative to the run's epoch to absolute
millisec comparable to System.currentTimeMillis().
|
long |
toAbsMillis(long relTimeNanos)
Converts the nanosecond time relative to the run's epoch to absolute
millisec comparable to System.currentTimeMillis().
|
long |
toAbsNanos(int relTimeMillis)
Converts the millisec relative time to absolute nanosecs.
|
long |
toAbsTime(long relNanos)
Obtains the nano time comparable to System.nanoTime() from a given
nanotime relative to the base time.
|
long |
toRelTime(long nanoTime)
Obtains the time relative to the base time, given a nanoTime
with an unknown datum.
|
void |
wakeupAt(long wakeupTime)
Causes this thread to sleep until the wakeup time as referenced
by this timer.
|
public Timer()
public long toAbsNanos(int relTimeMillis)
relTimeMillis
- The millisec relative timepublic long toAbsMillis(long relTimeNanos)
relTimeNanos
- The relative time in nanosecspublic long toAbsMillis(int relTimeMillis)
relTimeMillis
- The relative time in nanosecspublic int getTime()
public long toRelTime(long nanoTime)
nanoTime
- The nanotime obtained from System.nanoTime()public long toAbsTime(long relNanos)
relNanos
- The relative nanosecond timepublic long getCompensation()
public double getDeviation()
public void wakeupAt(long wakeupTime)
wakeupTime
- The time this thread is supposed to wakeup.public void idleTimerCheck(String id)
public void calibrate(String id, long startRamp, long endRamp)
id
- The agent identifier - used for logging purposes.startRamp
- The start of ramp upendRamp
- The end of ramp uppublic void adjustBaseTime(int offset)
offset
- The millisec offset between systems