next up previous contents
Next: Operations on Watch Up: Using StopWatch Previous: WatchesClocks and

Operations on Watches

StopWatch is used by inserting subroutine calls into your program. These subroutine calls correspond to the actions performed with a common stop watch. The basic operation of a watch involves starting it, stopping it, and resetting it's value to 0.

Of course, running a stop watch is of little use unless you can see what it says. The following routines can be called regardless of whether a watch is running, stopped or paused.

read_watch returns the clock value in the first argument. The result variable is either a scalar, a pointer to an array of rank one, or a pointer to an array of rank two depending on whether watch and clock are scalars or arrays. Unless it is a scalar, the result variable should be deallocated after use to avoid memory leakage.

When measuring CPU time, it is often desirable to not include the time used by certain parts of the code, such as printing or graphics. In a subroutine, you might not know which of the clocks are currently running, so you can not simply stop them before the I/O and start them up again after the I/O. For this, StopWatch provides the pause function.



next up previous contents
Next: Operations on Watch Up: Using StopWatch Previous: WatchesClocks and



william.mitchell@nist.gov