1

The end goal is to time the execution of individual parallel functions. If my understanding of clock() is correct, this measures elapsed time rather than cpu time.

I am looking for some alternative to:

clock_t t;
t=clock();
function();
clock_t elapsed_time = t - clock();
Josh Mathews
  • 198
  • 1
  • 15
  • Welcome to Stack Overflow. Please take few moments to take a [tour] and also read [ask] to get better answers for your questions. – Marek Vitek Jul 10 '17 at 17:37
  • 5
    Possible duplicate of [Measuring CPU time in c++](https://stackoverflow.com/questions/20167685/measuring-cpu-time-in-c) – Inline Jul 10 '17 at 17:38
  • Just simple quick search returns [How can I measure CPU time and wall clock time on both Linux/Windows?](https://stackoverflow.com/questions/17432502/how-can-i-measure-cpu-time-and-wall-clock-time-on-both-linux-windows) – Marek Vitek Jul 10 '17 at 17:38
  • 2
    You can use the chrono's [high_resolution_clock](http://en.cppreference.com/w/cpp/chrono/high_resolution_clock) and modify that example so that it casts to milliseconds. – Ron Jul 10 '17 at 17:40
  • You can't in C++ really. You'll have to resort OS APIs for that usually. – tambre Jul 10 '17 at 17:41
  • 1
    Possible duplicate of [How can I measure CPU time and wall clock time on both Linux/Windows?](https://stackoverflow.com/questions/17432502/how-can-i-measure-cpu-time-and-wall-clock-time-on-both-linux-windows) – AndyG Jul 10 '17 at 17:59

0 Answers0