测试 C++ 的性能代码
我可以使用哪些免费工具来测试 Linux 中 C++ 代码的性能?基本上我想确定代码的瓶颈并提高性能。我的应用程序主要涉及使用网络数据的计算代码。所以我想提高代码的执行速度。
谢谢。
What free tools could I use to test the performance of C++ code in Linux? Basically I want to identify the bottleneck of the code and improve on the performance. My application mainly involves computational code using the data from the network. So I would like to improve the speed of execution of the code.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
对于典型的性能基准测试,这就是我使用的。
现在您可以根据这些工具的输出来隔离问题。
例如:- 如果 I/O 恒定且在限制范围内,则可以消除 I/O 问题。
如果 CPU 使用率很高(如我的 mpstat 所示),则使用 gprof/oprofile 进行分析。
如果不将所有这些一起用于不同的运行,就很难识别瓶颈。
注意:您可以编写一个脚本来一起运行所有这些程序,并将每次运行的结果存储在指定的文件夹中。
For typical performance benchmarking this is what i use.
Now u can isolate the problems based on the output of these tools.
For eg:- if I/O is constant and within limits u can eliminate I/O as a problem.
If CPU usage is heavy as shown my mpstat then get into profiling using gprof/oprofile.
Without the use of all of them together for different runs, its difficult to identify the bottleneck.
Note: U can write a script to run all of them together and store the results in designated folders for each run.
我推荐 valgrind 用于
callgrind 输出可以通过 KCacheGrind 直观地显示。
I recommend valgrind for
The callgrind output can be visually displayed via KCacheGrind.
到目前为止,我所知道的最好的 Linux 分析器是 Zoom。虽然它是商业产品,但价格并不太贵,您可以根据要求获得免费的 30 天评估许可证
By far the best profiler for Linux that I know of is Zoom. Although it's a commercial product it's not too expensive and you can get a free 30 day evaluation licence on request
正如 @Paul 所说,尝试 Zoom 。
就我个人而言,我使用这种方法,它适用于这些原因,并且 Zoom 近似于此。这是一些程序员独立发现的技术。
我还被告知 OProfile 可以做到这一点,但您必须知道需要做什么才能做到这一点。
As @Paul says, give Zoom a try.
Personally, I use this method, which works for these reasons, and Zoom approximates it. It is a technique that some programmers have independently discovered.
I'm also told OProfile can do it, but you have to know what you need to make it do.