std::chrono::tai_clock::now (3) - Linux Manuals
std::chrono::tai_clock::now: std::chrono::tai_clock::now
Command to display std::chrono::tai_clock::now
manual in Linux: $ man 3 std::chrono::tai_clock::now
NAME
std::chrono::tai_clock::now - std::chrono::tai_clock::now
Synopsis
static std::chrono::time_point<std::chrono::tai_clock> now(); (since C++20)
Returns a time point representing the current point in time. The result is calculated as if by std::chrono::tai_clock::from_utc(std::chrono::utc_clock::now()). Implementations may use a more accurate value of TAI time.
Parameters
(none)
Return value
A time point representing the current time.
Example
// Run this code
#include <iostream>
#include <vector>
#include <numeric>
#include <chrono>
volatile int sink;
int main()
{
for (auto size = 1ull; size < 1000000000ull; size *= 100) {
// record start time
auto start = std::chrono::tai_clock::now();
// do some work
std::vector<int> v(size, 42);
sink = std::accumulate(v.begin(), v.end(), 0u); // make sure it's a side effect
// record end time
auto end = std::chrono::tai_clock::now();
std::chrono::duration<double> diff = end-start;
std::cout << "Time to fill and iterate a vector of "
<< size << " ints : " << diff.count() << " s\n";
}
}
Possible output:
Time to fill and iterate a vector of 1 ints : 2.43e-07 s
Time to fill and iterate a vector of 100 ints : 4.1e-07 s
Time to fill and iterate a vector of 10000 ints : 2.519e-05 s
Time to fill and iterate a vector of 1000000 ints : 0.00207669 s
Time to fill and iterate a vector of 100000000 ints : 0.423087 s
Pages related to std::chrono::tai_clock::now
- std::chrono::tai_clock::from_utc (3) - std::chrono::tai_clock::from_utc
- std::chrono::tai_clock::to_utc (3) - std::chrono::tai_clock::to_utc
- std::chrono::tai_clock (3) - std::chrono::tai_clock
- std::chrono::time_of_day (3) - std::chrono::time_of_day
- std::chrono::time_of_day<Duration>::hours,std::chrono::time_of_day<Duration>::minutes, (3) - std::chrono::time_of_day<Duration>::hours,std::chrono::time_of_day<Duration>::minutes,
- std::chrono::time_of_day<Duration>::make12,std::chrono::time_of_day<Duration>::make24 (3) - std::chrono::time_of_day<Duration>::make12,std::chrono::time_of_day<Duration>::make24
- std::chrono::time_of_day<Duration>::operatorprecision, (3) - std::chrono::time_of_day<Duration>::operatorprecision,
- std::chrono::time_of_day<Duration>::operatorprecision,std::chrono::time_of_day<Duration>::to_duration (3) - std::chrono::time_of_day<Duration>::operatorprecision,std::chrono::time_of_day<Duration>::to_duration
- std::chrono::time_of_day<Duration>::time_of_day (3) - std::chrono::time_of_day<Duration>::time_of_day
- std::chrono::time_point (3) - std::chrono::time_point
- std::chrono::time_point<Clock,Duration>::max (3) - std::chrono::time_point<Clock,Duration>::max
- std::chrono::time_point<Clock,Duration>::min (3) - std::chrono::time_point<Clock,Duration>::min
- std::chrono::time_point<Clock,Duration>::operator++, (3) - std::chrono::time_point<Clock,Duration>::operator++,
- std::chrono::time_point<Clock,Duration>::operator++,std::chrono::time_point<Clock,Duration>::operator-- (3) - - std::chrono::time_point<Clock,Duration>::operator++,std::chrono::time_point<Clock,Duration>::operator--
- std::chrono::time_point<Clock,Duration>::operator+,operator- (3) - - std::chrono::time_point<Clock,Duration>::operator+,operator-
- std::chrono::time_point<Clock,Duration>::time_point (3) - std::chrono::time_point<Clock,Duration>::time_point
- std::chrono::time_point<Clock,Duration>::time_since_epoch (3) - std::chrono::time_point<Clock,Duration>::time_since_epoch
- std::chrono::time_point_cast (3) - std::chrono::time_point_cast