1 | initial version |
The clock()
function measures the CPU ticks (operations) needed to do the processing and divides it with the processor frequency.
It is the same for parallel and serial operations - but it doesn't measure the real elapsed time in multi-core systems.
Use the standard chrono
library to measure precisely the processing time (you should enable C++11).
#include <chrono>
//....
std::chrono::time_point<std::chrono::system_clock> start, end;
std::chrono::duration<double> elapsed;
start = std::chrono::system_clock::now();
//...do the processing here...
end = std::chrono::system_clock::now();
elapsed=end-start;
cout<<"Processing time: "<<elapsed.count();