APIC – States development guide

Best Practices — State Architecture & Usage

CSimTimer – High Precision Timer Class

The CSimTimer class provides high-precision timing functionality using std::chrono::steady_clock to ensure monotonic and accurate time measurements. It can measure elapsed time, pause/resume, and handle delayed timers.

Key Features

Usage Example


// Create a timer
CSimTimer timer;

// Start the timer
timer.StartTimer(5000); // 5-second timer

// Perform some work...
while (!timer.IsTimeOver()) {
    // do work
}

// Check elapsed time since last mark
timer.SetMark();
// ...some operations...
auto elapsedMs = timer.GetElapsedMilliTimeFromMark();

This class is suitable for simulation loops, profiling, and time-sensitive operations, providing both high-resolution and robust timing guarantees across platforms.