I used this code to measure the runtime of my program from this answer
auto start = std::chrono::system_clock::now();
/* do some work */
auto end = std::chrono::system_clock::now();
auto elapsed = end - start;
std::cout << elapsed.count() << '\n';
I only needed to measure the runtime to look for a trend but I am kind of curious as to what unit that is.
You can easily check by your self, with this code:
using Clock = std::chrono::system_clock;
using Duration = Clock::duration;
std::cout << Duration::period::num << " , " << Duration::period::den << '\n';
On my system it prints:
1 , 1000000000
That is, a period in terms of nanoseconds (i.e. 10−9s).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With