DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Measuring Program Execution Time with Stopwatch(C++) - Stopwatch(C++)

Setting Operations

Calling the Stopwatch member function start() is analogous to pressing the START button; calling stop() is analogous to pressing the STOP button and calling reset() is analogous to pressing the RESET button.

       Stopwatch w;
       w.running()       returns zero    ...
       w.start();
       w.running()       returns non-zero    ...
       w.stop();
       w.running()       returns zero    ...
       w.reset();

As you can observe by calling the status() function, starting and stopping may affect the status. In particular, calling start() when a Stopwatch is not running causes the Stopwatch to begin running. If the displays initially contain non-zero values at the time of the call, they will continue to accumulate from their current values; if the displays initially contain zero, they will begin accumulating anew. Calling stop() when a Stopwatch is running causes accumulation to cease, leaving displays at their current values. Calling reset() resets all three displays to zero; if the Stopwatch is running when reset() is called, accumulation in each display continues (almost) instantaneously after resetting the displays to zero.

Calling stop() when a Stopwatch is not running has no effect. Similarly, calling start() when a Stopwatch is running has no effect.

Just as the operator's reaction time is included in a real stopwatch measurement, a certain overhead is also incurred by each of the Stopwatch setting operations. In some cases, this overhead merely amounts to the execution time for a few inline instructions. In other cases, it includes the time for a function call or a system call. The following operations incur a system call:


Next topic: Reading Operations
Previous topic: Stopwatch Status

© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 02 June 2005