简体   繁体   中英

C++ compiler flags for profiling in Visual Studio

To accurately profile an application, under linux , it is recommended to have optimizations on and debug symbols on via compile options -O2 -g for gcc or g++ . This enables profiling to include the user's C++ code and not point to assembly code instead as possible hotspots, for instance. See for instance, here .

In Visual Studio IDE, for usage of profilers, what are the equivalent compile/linking options?

In Release mode of Visual Studio, under "Whole Program Optimization" property sheet that comes loaded by default, the Debug Information Format gets set to Program Database with command line option /Zi . See image:

在此处输入图像描述

Is this the Visual Studio/Windows/MSVC (Cl.exe, MSBuild.exe) equivalent of -O2 -g ? Or are there any other equivalent settings?

ETA: Under the default Visual Studio 2019 release mode settings, the following flags are set:

/permissive- /ifcOutput "x64\Release\" /GS /GL /W3 /Gy /Zc:wchar_t /I"E:\local\boost_1_72_0" /Zi /Gm- /O2 /sdl /Fd"x64\Release\vc142.pdb" /Zc:inline /D "_MBCS" /errorReport:prompt /WX- /Zc:forScope /Gd /Oi /MD /FC /Fa"x64\Release\" /EHsc /nologo /Fo"x64\Release\" /FA /Fp"x64\Release\windows.pch" /diagnostics:column 

Have a look at the project properties, under C++ optimization. The IDE tells you everything.

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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