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? |
GetProcessTimes()
does that.
|
|
|
|
|
|
|
|
boost: processor 0.710 seconds boost: wall clock 2.709 seconds boost: CPU usage 26.2% clock: processor 0.709087 seconds. chrono: wall clock 2.709 seconds. |
Specifically for my factiorial implementation: ..... There is no way to measure the execution time with std::clock() because this execution takes less than one clock tick :( |
That's why I went to <chrono> because even though it's measuring wall clock time it has a higher resolution. .... My timing purpose is to look at relative differences between alternatives and the external conditions are conveniently for me about the same |
lastchance wrote: |
---|
Yes, I agree - for the reasons I have taken the liberty of putting in bold above. Usually, we aren't interested in the precise times taken by two approaches, but which is the faster and by how much. Most of the figures where there is a distinction show the processor time being consistently about a quarter of the wall time ... ... which brings me to my (hopefully) final grouse: what on earth is that processor doing taking 75% of its time away from dealing with my program?! Maybe that's why Microsoft doesn't want us to have too accurate a std::clock(). |
|
|
fac Iterations Av Exe Tm Av S/watch Tm 9.33262e+157 1 0.002 18832 9.33262e+157 10 0.0003 811 9.33262e+157 100 0.0003 344 9.33262e+157 1000 0.000304 314 9.33262e+157 10000 0.0002883 290 9.33262e+157 100000 0.00030632 306 9.33262e+157 1000000 0.000303465 304 9.33262e+157 10000000 0.000291497 291 Program ended with exit code: 0 |
|
|
|
|
fac Iterations Av ctime Av chrono (Times are in milliseconds) 9.33262e+157 1 0.0850000 0.0891060 9.33262e+157 10 0.0468000 0.0491970 9.33262e+157 100 0.0416400 0.0417340 9.33262e+157 1000 0.0419580 0.0422120 9.33262e+157 10000 0.0423668 0.0425300 9.33262e+157 100000 0.0395159 0.0395450 9.33262e+157 1000000 0.0397168 0.0397410 9.33262e+157 10000000 0.0401500 0.0401670 Program ended with exit code: 0 |
So when you do the sums it comes out as zero processor time. The conversion factor of CLOCKS_PER_SECOND and 1000 'destroy any value' |
If it's less than one clock interval then the discrete result will be 0 |
|
|
First execution: Fac iterative code Factorial value: 9.33262e+157 Execution time: 0.0304ms Fac recursively code Factorial value: 9.3326e+157 Execution time: 0.0380ms |
Second execution: Fac iterative code Factorial value: 9.33262e+157 Execution time: 0.0836ms Fac recursively code Factorial value: 9.3326e+157 Execution time: 0.0836ms |
Third execution: Fac iterative code Factorial value: 9.33262e+157 Execution time: 0.0912ms Fac recursively code Factorial value: 9.3326e+157 Execution time: 0.0760ms |
Run 0 Iter: 9.33262e+157 16.902 Rec: 9.33262e+157 17.828 Run 1 Iter: 9.33262e+157 15.731 Rec: 9.33262e+157 15.919 Run 2 Iter: 9.33262e+157 17.17 Rec: 9.33262e+157 18.509 Run 3 Iter: 9.33262e+157 16.079 Rec: 9.33262e+157 15.605 Run 4 Iter: 9.33262e+157 17.476 Rec: 9.33262e+157 17.671 Run 5 Iter: 9.33262e+157 15.76 Rec: 9.33262e+157 17.053 Run 6 Iter: 9.33262e+157 16.006 Rec: 9.33262e+157 15.327 Run 7 Iter: 9.33262e+157 15.215 Rec: 9.33262e+157 16.709 Run 8 Iter: 9.33262e+157 15.881 Rec: 9.33262e+157 15.877 Run 9 Iter: 9.33262e+157 15.215 Rec: 9.33262e+157 15.501 Program ended with exit code: 0 |
tick tick tick tick | | | | | run 1: three clock ticks | <---|---------------------|---------------------|----> | | | | | | | | | | | | run 2: two clock ticks | <------------|---------------------|----------------> | | | | | | | | tick tick tick tick |
|
|
"Launching <project> has encountered a problem. The problem file specified in the launch configuration does not exist" |
Boost.Timer is implemented as a separately compiled library, so you must install binaries in a location that can be found by your linker. If you followed the Boost Getting Started instructions http://www.boost.org/doc/libs/release/more/getting_started/index.html , that's already done for you http://www.boost.org/doc/libs/1_65_0/libs/timer/doc/cpu_timers.html |
|
|
In file included from ../src/funcionFactorialIteracionVsRecursividad.cpp:10:0: /usr/local/bin/boostCppLib/include/boost/timer/timer.hpp:11:44: fatal error: boost/config/warning_disable.hpp: No existe el archivo o el directorio #include <boost/config/warning_disable.hpp> |
/usr/bin/ld: cannot find -lboost_timer |
/home/victor/.dropbox-workspace/Dropbox/funcionFactorialIteracionVsRecursividad/Debug/funcionFactorialIteracionVsRecursividad: error while loading shared libraries: libboost_timer.so.1.65.0: cannot open shared object file: No such file or directory |