Accordingly: http://en.cppreference.com/w/cpp/chrono/duration the default coefficient for the second parameter of the template 1:1 means seconds.
Other meanings are relationships regarding this. For example, the ratio for std::chrono::milliseconds is 1:1000 http://en.cppreference.com/w/cpp/numeric/ratio/ratio
So this statement:
std::chrono::duration<double> elapsed_seconds = end-start;
is equivalent to:
std::chrono::duration<double, std::ratio<1>> elapsed_seconds = end-start;
Defined as seconds from which all other relationships are derived.
Regardless of which end - start units end - start defined when converting to std::ratio<1> , as in seconds.
If you need time in milliseconds, you can do:
std::chrono::duration<double, std::ratio<1, 1000>> elapsed_milliseconds = end-start;
And end - start should be converted in accordance with the new ratio.
Galik source share