How can I find the execution time of a section of my program in C?

后端 未结 11 1984
花落未央
花落未央 2020-12-31 05:23

I\'m trying to find a way to get the execution time of a section of code in C. I\'ve already tried both time() and clock() from time.h, but it seems that time() returns seco

11条回答
  •  臣服心动
    2020-12-31 05:30

    You won't find a library call which lets you get past the clock resolution of your platform. Either use a profiler (man gprof) as another poster suggested, or - quick & dirty - put a loop around the offending section of code to execute it many times, and use clock().

提交回复
热议问题