[英]c++ profiler that can attach to a running process?
I have a program written in c++ that I want to profile, and I want to avoid restarting it when I start and stop profiling. 我有一个要用c ++编写的程序,该程序要进行概要分析,并且我希望避免在启动和停止分析时重新启动它。 Ideally I would be profiling both CPU usage and memory allocation. 理想情况下,我将同时分析CPU使用率和内存分配。 Is there any tool that will allow me to do this? 有什么工具可以帮助我做到这一点? I'm running on Linux. 我在Linux上运行。
我的建议是RotateRight中的Zoom-您可以从他们的网站上下载30天的免费评估版。
If you can get by with simple metrics, in the past, I have implemented a simple profiler. 如果您可以通过简单的指标来解决问题,过去,我已经实现了一个简单的探查器。 Track memory and time. 追踪记忆和时间。 Track the start and stop of each function, print a line at the start and stop. 跟踪每个功能的开始和停止,在开始和停止处打印一行。 Track the memory before and after if important. 如果重要,请在此前后跟踪内存。 Have all of this gated by a runtime variable that you can change externally. 所有这些都由可以在外部更改的运行时变量来控制。 In a web application, it could be an extra post/get parameter. 在Web应用程序中,它可能是一个额外的post / get参数。 In a thick client program, it could be an extra switch. 在胖客户端程序中,这可能是一个额外的开关。
Then, at runtime, you could start to collect data. 然后,在运行时,您可以开始收集数据。 I have added multiple levels in the past as well to allow for selective and then more detailed data collection. 过去,我还添加了多个级别,以允许选择性地收集数据,然后进行更详细的数据收集。
Good luck. 祝好运。
You can try valgrind. 您可以尝试valgrind。 It is a bundle of different modules put together into a neat package 它是将不同模块捆绑在一起的整齐包装
Add metrics to your code. 将指标添加到您的代码中。 Profile with gprof http://linuxgazette.tuwien.ac.at/100/vinayak.html . 使用gprof进行配置文件http://linuxgazette.tuwien.ac.at/100/vinayak.html 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.