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

Reading Operations

Calling the member function system() is analogous to reading the SYSTEM display; calling user() is analogous to reading the USER display, and calling real() is analogous to reading the REAL display. Reading operations may be performed at any time, regardless of whether the Stopwatch is running or not. For convenience and portability, the reading operations return double precision values in units of seconds.

       Stopwatch w;
       w.start();
           computation of interest    w.stop();
       cout << "user time = " << w.user() << "\ n";

As with the setting operations, each reading operation also incurs a certain overhead. Reading any display on a stopped Stopwatch incurs (at worst) the overhead of a function call; reading any display on a moving Stopwatch always incurs a system call.


Next topic: Getting Meaningful Stopwatch Measurements
Previous topic: Setting Operations

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