I need to calculate the execution time of a C++ program. I am currently using the c-style head, <time.h> with the following code:
clock_t tStart = clock();
...
printf("Execution Time: %.2fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);
Is there a c++ header I can use to calculate execution time? Please note this needs to be cross-platform compatible.
You can use the C++ versions of C headers. Add ‘c’ at the beginning, and remove ‘.h’
So you need
The rest stays the same, as you can just use the C approach.