rdtsc timing for a measuring a function

前端 未结 2 924
悲哀的现实
悲哀的现实 2021-01-17 06:19

I want to time a function call with rdtsc. So I measured it in two ways as follows.

  1. Call it in a loop. Aggregate each rdtsc difference within the loop and divi
2条回答
  •  有刺的猬
    2021-01-17 06:53

    Have you tried clock_gettime(CLOCK_MONOTONIC, &tp)? Should be quite near to reading the cycle counter by hand, also keep in mind that the cycle counter may not be synchronized between cpu cores.

提交回复
热议问题