Oh! It has been quite a long conversation here :)
Overall, according with what
JLBorges said:
All the clocks in <chrono> measure the wrong time for this; they are not appropriate for this program
|
I cannot rely in the library <chrono>, although the class provided by
kemort looks interesting.
Specifically for my factiorial implementation:
1 2 3 4 5
|
while (tmp1>0){
fac*=tmp1;
tmp1--;
//cout << " #####fac: " <<fac;
}
|
There is no way to measure the execution time with std::clock() because this execution takes less than one clock tick :(
However I will try with the Boost CPU timers
JLBorges suggested. I wonder if with high precision I will be able to measure the execution....
In C++11 the library <chrono> adds a class high_resolution_clock. Could I rely on the function in two instances of
chrono::high_resolution_clock::now()
to calculate the execution time?
I also would like to point out the calculation of duration:
|
duration= 1000.0*(c_end - c_start) / CLOCKS_PER_SEC;
|
I noticed that c_start returns always 0. Is it then mandatory to do the subtraction?
I mean I think this would return the same result.
|
duration= 1000.0*(c_end) / CLOCKS_PER_SEC;
|
Finally a question for @Chervil:
What do you want to say with your last posted message? :)
Have you found a way to calculate the execution time with cpp in Windows?