1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <iostream>
#include <chrono>
#include <thread>
int main() {
using namespace std::chrono;
// Record the start time
auto start = high_resolution_clock::now();
// Simulate work by sleeping for 1 second
std::this_thread::sleep_for(seconds(1));
// Record the end time
auto end = high_resolution_clock::now();
// Calculate the elapsed time
duration<double> elapsed = end - start;
std::cout << "Elapsed time: " << elapsed.count() << " seconds" << std::endl;
return 0;
}
Back to std_chrono