This class is a stopwatch to measure computation times. It handles multiple simultaneous events, and allows for pausing and resetting each one individually. It measures both the elapsed time, and the total CPU time (different when computing in parallel). This program can be invoked from other source files by using the module StopwatchClass
program main
use StopwatchClass
...
The user just interacts with the Stopwatch class. The process to measure times is:
- Create an event. Each event is identified by a name (character)
call Stopwatch % CreateNewEvent("EventName")
- Start the event:
call Stopwatch % Start("EventName")
- Pause the event:
call Stopwatch % Pause("EventName")
- Get the times:
call Stopwatch % ElapsedTime("EventName")
call Stopwatch % CPUTime("EventName")
- Reset the event (if desired):
call Stopwatch % Reset("EventName")
NOTE: The time can be measured while the event is running. It just takes a measure of the actual time and compares it to the previous register.