# std::chrono::high_resolution_clock::now

C++
 Language Standard Library Headers Freestanding and hosted implementations Named requirements Language support library Concepts library (C++20) Diagnostics library Utilities library Strings library Containers library Iterators library Ranges library (C++20) Algorithms library Numerics library Input/output library Localizations library Regular expressions library (C++11) Atomic operations library (C++11) Thread support library (C++11) Filesystem library (C++17) Technical Specifications

Utilities library
Type support (basic types, RTTI, type traits)
Dynamic memory management
Error handling
Program utilities
Library feature-test macros
Date and time
Function objects
Formatting library (C++20)
(C++11)
Relational operators (deprecated in C++20)
Comparisons (C++20)
Integer comparison functions
(C++20)
Common vocabulary types
 pair tuple(C++11) apply(C++17) make_from_tuple(C++17)
 optional(C++17) any(C++17) variant(C++17)
Swap, forward and move
(C++14)
(C++11)
(C++11)
Elementary string conversions
(C++17)
(C++17)
Type operations
(C++11)
(C++17)
(C++17)

Date and time utilities
 duration(C++11) time_point(C++11) time_of_day(C++20)
 clock_time_conversion(C++20) clock_cast(C++20)
Clocks
 utc_clock(C++20) tai_clock(C++20) gps_clock(C++20) file_clock(C++20) local_t(C++20)
Calendars
 day(C++20) month(C++20) year(C++20) weekday(C++20) operator/(C++20) year_month_day(C++20) year_month_day_last(C++20) year_month_weekday(C++20) year_month_weekday_last(C++20)
 weekday_indexed(C++20) weekday_last(C++20) month_day(C++20) month_day_last(C++20) month_weekday(C++20) month_weekday_last(C++20) year_month(C++20)
Time zones
 time_zone(C++20) locate_zone(C++20) current_zone(C++20) zoned_time(C++20) link(C++20) leap(C++20)
C-style date and time

std::chrono::high_resolution_clock
 Member functions high_resolution_clock::now

 static std::chrono::time_point now() noexcept; (since C++11)

Returns a time point representing the current point in time.

(none)

### Return value

A time point representing the current time.

### Example

#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::high_resolution_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::high_resolution_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
{"ft_lang_label":"__label__en","ft_lang_prob":0.537096,"math_prob":0.9480912,"size":1300,"snap":"2020-10-2020-16","text_gpt3_token_len":365,"char_repetition_ratio":0.14351852,"word_repetition_ratio":0.14572865,"special_character_ratio":0.34615386,"punctuation_ratio":0.24452555,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9887942,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-04-03T18:06:57Z\",\"WARC-Record-ID\":\"<urn:uuid:f3f663f5-5f7f-40ab-99cb-01da90d4d2c9>\",\"Content-Length\":\"63424\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:9d6a8f5a-0fe7-4d94-80dc-6a3465354297>\",\"WARC-Concurrent-To\":\"<urn:uuid:c12edc45-3195-4053-9b60-776e752f6880>\",\"WARC-IP-Address\":\"74.114.90.46\",\"WARC-Target-URI\":\"https://en.cppreference.com/w/cpp/chrono/high_resolution_clock/now\",\"WARC-Payload-Digest\":\"sha1:JGEV4KSIIA7KNXRS4QG26DEX7YTDKXMK\",\"WARC-Block-Digest\":\"sha1:D24LCS3O236ACTEWBIZKFN7VA3YSKCDQ\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-16/CC-MAIN-2020-16_segments_1585370515113.54_warc_CC-MAIN-20200403154746-20200403184746-00390.warc.gz\"}"}