How do you time execution time?. I am writing a program in C++ to calculate Pi with a desired degree of precision/digits after the decimal point, and I have to calculate the time it takes to calculate for each desired precision. Can anyone help me? :o
Jump to Post
If you want any decent timings, you'll use a profiler. But you can use a poor man's timer with the standard library. For example:…
#include <ctime> std::clock_t start = std::clock(); /* Stuff to time here */ std::cout<< ( ( std::clock() - start ) / (double)CLOCKS_PER_SEC ) <<'\n';
All 7 Replies
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.