AbstractChrono is the base class for timer (stopwatch) objects that can measure the CPU time or wall clock time elapsed when executing parts of a program. More...
Timing functions @{ | |
| void | init () |
| Initializes this AbstractChrono to zero. | |
| double | getSeconds () |
| Returns the CPU time in seconds used by the program since the last call to init for this AbstractChrono. | |
| double | getMinutes () |
| Returns the CPU time in minutes used by the program since the last call to init for this AbstractChrono. | |
| double | getHours () |
| Returns the CPU time in hours used by the program since the last call to init for this AbstractChrono. | |
| String | format () |
| Converts the CPU time used by the program since its last call to init for this AbstractChrono to a String in the HH:MM:SS.xx format. | |
| static String | format (double time) |
| Converts the time time, given in seconds, to a String in the HH:MM:SS.xx format. | |
AbstractChrono is the base class for timer (stopwatch) objects that can measure the CPU time or wall clock time elapsed when executing parts of a program.
Its main implementations are the Chrono and ChronoWall classes.
Every object of class AbstractChrono acts as an independent stopwatch. Several AbstractChrono objects can run at any given time. The method init resets the stopwatch to zero, getSeconds, getMinutes and getHours return its current reading, and format converts this reading to a String. The returned value includes the execution time of the method from AbstractChrono.
Below is an example of how it may be used. A stopwatch named timer is constructed (and initialized). When 2.1 seconds of CPU time have been consumed, the stopwatch is read and reset to zero. Then, after an additional 330 seconds (or 5.5 minutes) of CPU time, the stopwatch is read again and the value is printed to the output in minutes.
(suppose 2.1 CPU seconds are used here.)
(suppose 330 CPU seconds are used here.)
Definition at line 71 of file AbstractChrono.java.
| String umontreal.ssj.util.AbstractChrono.format | ( | ) |
Converts the CPU time used by the program since its last call to init for this AbstractChrono to a String in the HH:MM:SS.xx format.
Definition at line 137 of file AbstractChrono.java.
|
static |
Converts the time time, given in seconds, to a String in the HH:MM:SS.xx format.
Definition at line 147 of file AbstractChrono.java.
| double umontreal.ssj.util.AbstractChrono.getHours | ( | ) |
Returns the CPU time in hours used by the program since the last call to init for this AbstractChrono.
Definition at line 125 of file AbstractChrono.java.
| double umontreal.ssj.util.AbstractChrono.getMinutes | ( | ) |
Returns the CPU time in minutes used by the program since the last call to init for this AbstractChrono.
Definition at line 113 of file AbstractChrono.java.
| double umontreal.ssj.util.AbstractChrono.getSeconds | ( | ) |
Returns the CPU time in seconds used by the program since the last call to init for this AbstractChrono.
Definition at line 101 of file AbstractChrono.java.
| void umontreal.ssj.util.AbstractChrono.init | ( | ) |
Initializes this AbstractChrono to zero.
Definition at line 89 of file AbstractChrono.java.