Looking for a low impact c++ profiler

霸气de小男生 提交于 2019-12-20 09:44:35

问题


I am looking for a low impact, os-independent profiler for c++ code.

When I say low impact, I am referring to something less intrusive than valgrind. I plan to use it in a MIPS-based embeded environment (hence the os-independance) and tried a ported version of valgrind and it completely changed the performance characteristics (way too much Heisenberg principle at work) so I cant go that route. We know the memory bus speed is a bottleneck which most-likely explains why valgrind was so intrusive.

I have created a home grown type of profiler based on checkpoints that lets me measure certain parts of the code. Basically I have to modify the code (and recompile) to set checkpoints in strategic places in the code. Then, when executed, it stores the number of times each checkpoint is hit and the time since the last checkpoint was hit. Then, after running it, I can dump the checkpoints and for each it calculates: num-hits, max-time, min-time, avg-time, etc.

This profiler (I called it LowImpactProfiler) works ok, but I wonder if there is something better out there.

Ive considered oProfile, which is a sampling profiler, but since Im not running Linux, I think it will be really dificult to implement.


回答1:


I've used Shiny to profile on very limited embedded devices with great success. From your description, it takes a similar approach to your LowImpactProfiler.




回答2:


If you are using Windows, you can try my profiler, described here http://ravenspoint.wordpress.com/2010/06/16/timing/

It sounds like it might be easier to use than yours, but it is not OS independent. It uses calls to QueryPerformanceCounter() which is a windows API. It is open source, so it might be worthwhile to port it to your OS, using whatever high performance timer is available there.



来源:https://stackoverflow.com/questions/10433971/looking-for-a-low-impact-c-profiler

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!