example4_different_clocks.cpp

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
#include <iostream>
#include <chrono>

int main() {
    using namespace std::chrono;

    // Get the current time from system_clock
    auto sys_time = system_clock::now();
    std::cout << "System clock time since epoch: " << sys_time.time_since_epoch().count() << " ticks\n";

    // Get the current time from steady_clock
    auto steady_time = steady_clock::now();
    std::cout << "Steady clock time since epoch: " << steady_time.time_since_epoch().count() << " ticks\n";

    // Get the current time from high_resolution_clock
    auto high_res_time = high_resolution_clock::now();
    std::cout << "High resolution clock time since epoch: " << high_res_time.time_since_epoch().count() << " ticks\n";

    return 0;
}
Back to std_chrono