Difference between std::system_clock and std::steady_clock?

From N3376: 20.11.7.1 [time.clock.system]/1: Objects of class system_clock represent wall clock time from the system-wide realtime clock. 20.11.7.2 [time.clock.steady]/1: Objects of class steady_clock represent clocks for which values of time_point never decrease as physical time advances and for which values of time_point advance at a steady rate relative to real time. That is, the clock … Read more

How do I convert a std::chrono::time_point to long and back?

std::chrono::time_point<std::chrono::system_clock> now = std::chrono::system_clock::now(); This is a great place for auto: auto now = std::chrono::system_clock::now(); Since you want to traffic at millisecond precision, it would be good to go ahead and covert to it in the time_point: auto now_ms = std::chrono::time_point_cast<std::chrono::milliseconds>(now); now_ms is a time_point, based on system_clock, but with the precision of milliseconds instead … Read more

How to get duration, as int milli’s and float seconds from ?

Is this what you’re looking for? #include <chrono> #include <iostream> int main() { typedef std::chrono::high_resolution_clock Time; typedef std::chrono::milliseconds ms; typedef std::chrono::duration<float> fsec; auto t0 = Time::now(); auto t1 = Time::now(); fsec fs = t1 – t0; ms d = std::chrono::duration_cast<ms>(fs); std::cout << fs.count() << “s\n”; std::cout << d.count() << “ms\n”; } which for me prints … Read more