Is there something like clock () that works better for parallel code?

So, I know that clock () measures clock cycles and therefore is not very good for measuring time, and I know that there are functions like omp_get_wtime () to get time on a wall, but it seems to me that wall time varies so much, and it was interesting if there was a way to measure individual clock cycles (only one cycle, even if more than one thread is running in it). It should be something relatively simple / native. Thanks

+4
source share
2 answers

See FreeMemory's answer to this question for RDTSC if you are using x86, which I tested and seems to work fine on my system (mac), but see my answer to this question . Also see Criticism of the RDTSC here .

Usually you should not go down to a too low level of detail, although other bits and pieces of work that the computer must do will use clock cycles, so they will vary depending on the load. I find omp_get_wtime() sufficient, although I need to put my code in an extra loop to make sure it takes about a second to ensure consistent run results from launch.

0
source

Are you sure time measurement will not work for you? Remember that you can only measure up to a few milliseconds, depending on the OS.

+1
source

Source: https://habr.com/ru/post/1304429/


All Articles