简体   繁体   English

应该为分析设置哪个编译选项?

[英]Which compilation option should be set for profiling?

I need to profile an application compiled with intel's compiler via VC++. 我需要通过VC ++分析用intel编译器编译的应用程序。 I'm using VTune to profile my code. 我正在使用VTune来分析我的代码。

My understanding is that in release mode I won't have the debug information that is necessary for the profiler to profile my code while in debug mode, the result of the profiling will not be pertinent. 我的理解是,在发布模式下,我将没有调试器在调试模式下分析我的代码所需的调试信息,分析的结果将不相关。

What should I do ? 我该怎么办 ? Is it possible to add debug info in release mode? 是否可以在发布模式下添加调试信息? How can I set this mode? 我该如何设置此模式?

If so, will I still benefit from all the optimization (inlining etc.)? 如果是这样,我还能从所有优化(内联等)中受益吗?

You should certainly profile with optimisations enabled (compiler option /O3). 您当然应该启用优化配置文件(编译器选项/ O3)。 /Zi is the Intel compiler switch (on Windows) to enabled debugging information. / Zi是英特尔编译器开关(在Windows上)启用调试信息。

Because of the optimisations, some functions may be missing from the debugging information due to inlining, but VTune will cope with that. 由于优化,由于内联,调试信息中可能缺少某些功能,但VTune将应对此问题。

You can generate program database files (PDB) even in release target. 即使在发布目标中,您也可以生成程序数据库文件(PDB)。 Go to project properties, Linker/Debugging and check the option "Generate Program Database File". 转到项目属性,链接器/调试并选中“生成程序数据库文件”选项。 It is usually something like "$(TargetDir)$(TargetName).pdb". 它通常类似于“$(TargetDir)$(TargetName).pdb”。 Now, it depends whether VTune knows how to interpret PDB files... 现在,它取决于VTune是否知道如何解释PDB文件......

Function inlining and interprocess optimizations will make your profile hard to interpret. 函数内联和进程间优化将使您的配置文件难以解释。 That is why it is a good idea to profile in both debug and release modes. 这就是为什么在调试和发布模式下进行配置是个好主意的原因。 If release mode only shows function foo using 80% of the program time, you can use the debug profile to see that function bar, which was inlined into foo, is using 60% of foo's time. 如果释放模式仅使用80%的程序时间显示函数foo,则可以使用调试配置文件查看内联到foo的函数栏正在使用foo时间的60%。

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

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