measure time in a function in C

后端 未结 5 2095
南方客
南方客 2021-02-09 17:14

I\'m debugging an C application and I\'d like to know how much time it spends in a particular function.

I could change the source code and add some more code to do the m

5条回答
  •  礼貌的吻别
    2021-02-09 17:28

    Put this into your ~/.gdbinit

    define timeme
        python import time
        python starttime=time.time()
        next
        python print("Previous takes: " + (str)(time.time()-starttime) + "s")
    end
    document timeme
        Measure executing time of next function
        Usage: timeme or ti
    end
    

    type timeme or ti when you want to measure the time of next function.

提交回复
热议问题