class steady_clock;
| member type | definition | notes |
|---|---|---|
| rep | An arithmetic type (or a class that emulates it) | Used to store a count of periods. |
| period | A ratio type | Represents the length of a period in seconds. |
| duration | duration<rep,period> | The clock's duration type. |
| time_point | time_point<steady_clock> | The clock's time_point type. |
| member constant | definition |
|---|---|
| is_steady | true |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// steady_clock example
#include <iostream>
#include <ctime>
#include <ratio>
#include <chrono>
int main ()
{
using namespace std::chrono;
steady_clock::time_point t1 = steady_clock::now();
std::cout << "printing out 1000 stars...\n";
for (int i=0; i<1000; ++i) std::cout << "*";
std::cout << std::endl;
steady_clock::time_point t2 = steady_clock::now();
duration<double> time_span = duration_cast<duration<double>>(t2 - t1);
std::cout << "It took me " << time_span.count() << " seconds.";
std::cout << std::endl;
return 0;
}
printing out 1000 stars... ******************************************************************************** ******************************************************************************** ******************************************************************************** ******************************************************************************** ******************************************************************************** ******************************************************************************** ******************************************************************************** ******************************************************************************** ******************************************************************************** ******************************************************************************** ******************************************************************************** ******************************************************************************** **************************************** It took me 0.112006 seconds.