Quick and dirty way to profile your code

后端 未结 7 509
轮回少年
轮回少年 2020-12-04 18:25

What method do you use when you want to get performance data about specific code paths?

相关标签:
7条回答
  • 2020-12-04 19:16

    I have a quick-and-dirty profiling class that can be used in profiling in even the most tight inner loops. The emphasis is on extreme light weight and simple code. The class allocates a two-dimensional array of fixed size. I then add "checkpoint" calls all over the place. When checkpoint N is reached immediately after checkpoint M, I add the time elapsed (in microseconds) to the array item [M,N]. Since this is designed to profile tight loops, I also have "start of iteration" call that resets the the "last checkpoint" variable. At the end of test, the dumpResults() call produces the list of all pairs of checkpoints that followed each other, together with total time accounted for and unaccounted for.

    0 讨论(0)
提交回复
热议问题