spsig / cpp-build-insights-samples

Code samples for the C++ Build Insights SDK

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

page_type languages products description urlFragment
sample
C++
cpp-build-insights
This repository provides buildable and runnable samples for the C++ Build Insights SDK. Use it as a learning resource.
cpp-build-insights-samples

C++ Build Insights SDK samples

License

This repository provides buildable and runnable samples for the C++ Build Insights SDK. Use it as a learning resource.

Contents

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.

Prerequisites

In order to build and run the samples in this repository, you need:

  • Visual Studio 2017 and above.
  • Windows 8 and above.

Build steps

  1. Clone the repository on your machine.
  2. Open the Visual Studio solution file. Each sample is a separate project within the solution.
  3. All samples rely on the C++ Build Insights SDK NuGet package. Restore NuGet packages and accept the license for the SDK.
  4. Build the desired configuration for the samples that interest you. Available platforms are x86 and x64, and available configurations are Debug and Release.
  5. Samples will be built in their own directory following this formula: {RepositoryRoot}\out\{SampleName}.

Running the samples

  1. 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.
  2. Collect a trace of the build you want to analyze with the sample. You can do this using two methods:
    1. Use vcperf:
      1. Open an elevated x64 Native Tools Command Prompt for VS 2019.
      2. Run the following command: vcperf /start MySessionName
      3. Build your project. You do not need to use the same command prompt for building.
      4. Run the following command: vcperf /stopnoanalyze MySessionName outputTraceFile.etl
    2. Programmatically: see the C++ Build Insights SDK documentation for details.
  3. Invoke the sample, passing your trace as the first parameter.

Contributing

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.

About

Code samples for the C++ Build Insights SDK

License:MIT License


Languages

Language:C++ 100.0%