next up previous contents
Next: Display objects Up: Timer Previous: Nonvirtual member functions

Method of use

The functions start(), stop(), and clear() are used to start, stop and clear a Timer. The functions clock_time(), cpu_time(), user_time(), and system_time() are used to report the current values of a Timer.

As example, to time both the total time to complete a loop and each iteration of the loop, the following code could be used:

 
 		 Timer total_time; \+

Timer iter_time;

total_time.start();

while ( . . .)

{ \+

iter_time.start();

. . .

iter_time.stop();

printf("ITERATION TOOK %f seconds n", iter_time.clock_time());

iter_time.clear();

}

total_time.stop();

printf("TOTAL TIME %f seconds n", total_time.clock_time());



Justin Gullingsrud
Tue Apr 6 09:26:48 CDT 1999