简体   繁体   English

在MacOSX上分析g ++应用程序?

[英]Profiling g++ app on MacOSX?

My standard Linux way of profiling app is: 我的标准Linux分析应用程序方式是:

1) compile with g++ -pg
2) run prog
3) gprof

Apparently gprof is broek on MacOSX 10.5, and I am supposed to use Shark. 显然gprof在MacOSX 10.5上很流行,我应该使用Shark。 All the tutorials I've found aby Shark involves XCode (whereas my build is done with Makefiels and g++). 我发现aby Shark的所有教程都涉及XCode(而我的构建是用Makefiels和g ++完成的)。

Can someone post step by step instructions for using shark on an app built with g++? 有人可以发布在使用g ++构建的应用程序上使用shark的分步说明吗? Say something like: 说出类似的话:

int main() { while(1); }

g++ blah.cpp -o blah; do I need to give it more command line arguments?

how do I use shark here?

Instrumented profiling such as gprof is not particularly useful unless you really just want to know about call graphs and the number of times that functions are called. 除非你真的只想知道调用图和调用函数的次数,否则像gprof这样的有组织的分析并不是特别有用。 Much more useful for performance analysis is a sampling profiler, and for this Apple's Shark tool (part of CHUD) is one of the best. 对性能分析更有用的是采样分析器,对于这个Apple的Shark工具(CHUD的一部分)是最好的之一。

You really don't need to use Xcode to build an app for profiling under Shark - I have command line tools built with Makefiles that I profile with Shark all the time. 你真的不需要使用Xcode来构建一个用于在Shark下进行性能分析的应用程序 - 我有使用Makefiles构建的命令行工具,我一直在使用Shark进行分析。 You can either trigger Shark automatically from within your code (there are a couple of different APIs for this) or you can use the "chudRemoteCtrl" command line tool ( man chudRemoteCtrl ) or you can just configure the Launch options in Shark to set the executable path, working directory, command line arguments, etc, and away you go. 您可以从代码中自动触发Shark(有几个不同的API),或者您可以使用“chudRemoteCtrl”命令行工具( man chudRemoteCtrl ),或者您可以在Shark中配置启动选项来设置可执行文件路径,工作目录,命令行参数等,然后离开。 Make sure you build your app with -g so that Shark can display source code rather than disassembled object code. 确保使用-g构建应用程序,以便Shark可以显示源代码而不是反汇编的对象代码。

Shark configuration for command line tool http://www.freeimagehosting.net/uploads/386737a1fa.jpg 命令行工具的Shark配置http://www.freeimagehosting.net/uploads/386737a1fa.jpg

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM