Elapsed Time: Automation Classes

OverviewHow Do I

This procedure shows how to calculate the difference between two CTime objects and get a CTimeSpan result.

To calculate elapsed time

  1. Create two COleDateTime objects.

  2. Set one of the COleDateTime objects to the current time.

  3. Perform some time-consuming task.

  4. Set the other COleDateTime object to the current time.

  5. Take the difference between the two times.

    COleDateTime timeStart, timeEnd;
    timeStart = COleDateTime::GetCurrentTime();
    // ... perform time-consuming task
    timeEnd = COleDateTime::GetCurrentTime();
    COleDateTimeSpan spanElapsed = timeEnd - timeStart;