Timer to find elapsed time in a function call in C

后端 未结 11 1645
故里飘歌
故里飘歌 2020-12-09 14:20

I want to calculate time elapsed during a function call in C, to the precision of 1 nanosecond.

Is there a timer function available in C to do it?

If yes ple

11条回答
  •  误落风尘
    2020-12-09 14:44

    I don't know if you'll find any timers that provide resolution to a single nanosecond -- it would depend on the resolution of the system clock -- but you might want to look at http://code.google.com/p/high-resolution-timer/. They indicate they can provide resolution to the microsecond level on most Linux systems and in the nanoseconds on Sun systems.

提交回复
热议问题