page_type | languages | products | description | urlFragment | ||
---|---|---|---|---|---|---|
sample |
|
|
This repository provides buildable and runnable samples for the C++ Build Insights SDK. Use it as a learning resource. |
cpp-build-insights-samples |
This repository provides buildable and runnable samples for the C++ Build Insights SDK. Use it as a learning resource.
Sample | Description |
---|---|
BottleneckCompileFinder | Finds CL invocations that are bottlenecks and don't use /MP. |
FunctionBottlenecks | Prints a list of functions that are code generation bottlenecks within their CL or Link invocation. |
LongCodeGenFinder | Lists the functions that take more than 500 milliseconds to generate in your entire build. |
RecursiveTemplateInspector | Identifies costly recursive template instantiations. |
TopHeaders | Determines which headers you might want to precompile. |
LongModuleFinder | Identifies costly module interface IFC creation. Requires trace with code built using MSVC version 16.10 or later and using SDK version Microsoft.Cpp.BuildInsights 1.2.0 or later. |
LongHeaderUnitFinder | Identifies costly header unit IFC creation. Requires trace with code built using MSVC version 16.10 or later and using SDK version Microsoft.Cpp.BuildInsights 1.2.0 or later. |
LongPrecompiledHeaderFinder | Identifies costly precompiled header (PCH) IFC creation. Requires trace with code built using MSVC version 16.10 or later and using SDK version Microsoft.Cpp.BuildInsights 1.2.0 or later. |
In order to build and run the samples in this repository, you need:
- Visual Studio 2017 and above.
- Windows 8 and above.
- Clone the repository on your machine.
- Open the Visual Studio solution file. Each sample is a separate project within the solution.
- All samples rely on the C++ Build Insights SDK NuGet package. Restore NuGet packages and accept the license for the SDK.
- Build the desired configuration for the samples that interest you. Available platforms are x86 and x64, and available configurations are Debug and Release.
- Samples will be built in their own directory following this formula:
{RepositoryRoot}\out\{SampleName}
.
- The samples require CppBuildInsights.dll and KernelTraceControl.dll to run. These files are available in the C++ Build Insights NuGet package. When building samples, these files are automatically copied next to them in their respective output directory. If you are going to move a sample around on your machine, please be sure to move these DLL's along with it.
- Collect a trace of the build you want to analyze with the sample. You can do this using two methods:
- Use vcperf:
- Open an elevated x64 Native Tools Command Prompt for VS 2019.
- Run the following command:
vcperf /start MySessionName
- Build your project. You do not need to use the same command prompt for building.
- Run the following command:
vcperf /stopnoanalyze MySessionName outputTraceFile.etl
- Programmatically: see the C++ Build Insights SDK documentation for details.
- Use vcperf:
- Invoke the sample, passing your trace as the first parameter.
This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.
When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.