Getting Started | Documentation | Glish | Learn More | Programming | Contact Us |
Version 1.9 Build 1556 |
|
Package | utility | |
Module | misc |
include "stopwatch.g"
stopwatch | Construct stopwatch tool |
delete | destroy the tool |
fmtvalue | formatted string value of timer with units |
help | display help |
reset | reset time value to zero |
show | show value and run state of timer |
start | start timer running |
state | get run state of timer |
stop | stop timer |
timefunc | time a function |
value | get numerical value of timer in seconds |
zero | stop and reset timer |
The stopwatch class provides a set of timer functions with the functionality of a traditional stopwatch. Any number of stopwatches may be created, which can then individually be started, stopped, reset, displayed and interrogated. A function can be passed to a stopwatch, which is then run and timed. This is particularly useful for benchmarking purposes. Due to the distributed process nature of AIPS++, it is very difficult correctly to account for all the resources used by a given calculation. Thus only wall clock time is implemented in this class, as opposed to the ``system, user and wall clock'' accounting often found in simple single threaded applications. Multiple stopwatch timers will not interfere with each other.
- include "stopwatch.g" # no timer is created by default T - tim := stopwatch() - tim.show() # timer created running timer is RUNNING, value is 3.56s F - tim.stop() # stop and start timer stopped at 9.31s F - tim.show() timer is STOPPED, value is 9.31s F - tim.start() # restartable timer restarted from 9.31s F -tim.reset() # reset doesn't change state timer reset to zero F - tim.show() timer is RUNNING, value is 12.35s F - tim.stop() # values can be retrieved timer stopped at 1m 8.73s F - tim.value() 68.733093 - tim.fmtvalue() 1m 8.73s - tim.state() STOPPED - tim.start(quiet=T) # suppress messages - split_time := tim.value() # a value while running is a split time - split_time 74.526214
See timefunc for examples of how to time functions. stopwatch tools also provide standard functions ok() and delete().