A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://cplusplus.com/reference/chrono/steady_clock/ below:

class

<chrono>

std::chrono::steady_clock

Steady clock

Clock classes provide access to the current time_point.

steady_clock is specifically designed to calculate time intervals.



Clock properties
monotonic
Its member now never returns a lower value than in a previous call.
steady
Every tick the clock advances takes the same amount of time (in terms of physical time).

Member types The following aliases are member types of 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 constants member constant definition is_steady true
Static member functions
now
Get current time (public static member function)

Example
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;
}

Possible output:
printing out 1000 stars...
********************************************************************************
********************************************************************************
********************************************************************************
********************************************************************************
********************************************************************************
********************************************************************************
********************************************************************************
********************************************************************************
********************************************************************************
********************************************************************************
********************************************************************************
********************************************************************************
****************************************
It took me 0.112006 seconds.


See also
system_clock
System clock (class)
high_resolution_clock
High resolution clock (class)

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4