xcode 在 mac 上进行 C++ 分析
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6975261/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
C++ Profiling on mac
提问by sashab
I'm writing STL-only C++ application on mac(OS X Lion / XCode 4.1). I need to answer a simple question: which parts of code must be optimized? Gprof does empty output, XCode's Instruments doesn't help. Which tool I need to use?
我正在 mac(OS X Lion / XCode 4.1)上编写 STL-only C++ 应用程序。我需要回答一个简单的问题:代码的哪些部分必须优化?Gprof 做空输出,XCode 的仪器没有帮助。我需要使用哪种工具?
采纳答案by koan
Use Shark. It's in /Developer/Applications/Performance Tools
使用鲨鱼。在里面/Developer/Applications/Performance Tools
Very easy to use. More here: http://developer.apple.com/tools/sharkoptimize.html
非常容易使用。更多信息:http: //developer.apple.com/tools/sharkoptimize.html
回答by Mike Dunlavey
Even if gprofwere working, it would probably not be much help.
即使gprof正在工作,它也可能没有太大帮助。
The method I rely on, for any language and OS, is random pausing.
对于任何语言和操作系统,我所依赖的方法是随机暂停。
Here's how it works. If you take several random-time samples of the stack, wasteful function calls or I/O appear in proportion to the fraction of time they waste. It has the advantage that problematic statementsare pinpointed, as opposed to making you hunt within costly routines.
这是它的工作原理。如果您对堆栈进行多个随机时间采样,则浪费的函数调用或 I/O 的出现与它们浪费的时间比例成正比。它的优点是可以查明有问题的语句,而不是让您在昂贵的例程中寻找。