Timing multiple events

If you need to start and stop the timer more than once, you must use the EmptyStartStopTimingTest member function to offset the time overhead caused by starting and stopping the timer.

This example shows the functions you need to write to start and stop the timer three times during a timing test.

The StartStopTimingTest member function contains the actions you want to time. Start and stop the timer for each action.

      void TSampleStartStopRestartTest::StartStopTimingTest(TTimingTestStopwatch& stopwatch)
      {
              stopwatch.Start();
          for (short i=0; i<1000;i++); 
              stopwatch.Stop();
      
              stopwatch.Start();
          for (i=0; i<1000;i++); 
              stopwatch.Stop();
      
              stopwatch.Start();
          for (i=0; i<1000;i++); 
              stopwatch.Stop();
      }
The EmptyStartStopTimingTest member function contains the same number of start and stop calls as your StartStopTimingTest member function.

      void TSampleStartStopRestartTest::EmptyStartStopTimingTest(TTimingTestStopwatch& stopwatch)
      {
              stopwatch.Start();
              stopwatch.Stop();
              
              stopwatch.Start();
              stopwatch.Stop();
      
              stopwatch.Start();
              stopwatch.Stop();
              
      }
This is the output from the TSampleStartStopRestartTest::StartStopTimingTest:

    Test TSampleStartStopRestartTest ( Pass ) {time 570 +/- 180 us}


[Contents] [Previous] [Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.

Generated with WebMaker