#include <chrono>
#include <iostream>
int main()
{
std::chrono::nanoseconds ns(9'000'000);
std::chrono::microseconds us(60'000);
std::chrono::milliseconds ms(300);
std::chrono::seconds s(1);
std::chrono::high_resolution_clock::duration hrc_duration = s + ms + us + ns;
double hrc_seconds = double(hrc_duration.count()) *
std::chrono::high_resolution_clock::period::num /
std::chrono::high_resolution_clock::period::den;
std::cout << hrc_seconds << std::endl;
return 0;
}
// Output: 1.369
Reference: http://en.cppreference.com/w/cpp/chrono/duration
Tuesday, August 29, 2017
C++11: Time: Durations
C++11 has new duration types that can be used with the new time functions.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment