package umontreal.iro.lecuyer.util;
/**
* Extends the {@link AbstractChrono} class to compute
* the total system time using Java's builtin System.nanoTime.
* The system can be used as a rough approximation of the CPU time taken
* by a program if no
* other tasks are executed on the host while the program is running.
*
*/
public class SystemTimeChrono extends AbstractChrono {
protected void getTime (long[] tab) {
long rawTime = System.nanoTime();
final long DIV = 1000000000L;
long seconds = rawTime/DIV;
long micros = (rawTime % DIV)/1000L;
tab[0] = seconds;
tab[1] = micros;
}
/**
* Constructs a new chrono object and
* initializes it to zero.
*
*/
public SystemTimeChrono() {
super();
init();
}
}
Ads help maintain this website.