|
| 1 | +--- |
| 2 | +title: "Get started with C++ Build Insights" |
| 3 | +description: "A high-level overview of how to use the build-time performance analysis tools that are part of C++ Build Insights." |
| 4 | +ms.date: "11/03/2019" |
| 5 | +helpviewer_keywords: ["C++ Build Insights", "throughput analysis", "build time analysis", "vcperf.exe"] |
| 6 | +--- |
| 7 | +# Get started with C++ Build Insights |
| 8 | + |
| 9 | +::: moniker range="<=vs-2017" |
| 10 | + |
| 11 | +The C++ Build Insights tools are available in Visual Studio 2019. To see the documentation for that version, set the Visual Studio version selector control for this article to Visual Studio 2019. |
| 12 | + |
| 13 | +::: moniker-end |
| 14 | +::: moniker range="vs-2019" |
| 15 | + |
| 16 | +C++ Build Insights is a collection of tools that provides increased visibility into the Microsoft Visual C++ (MSVC) tool chain. The tools collect data about your C++ builds, and present it in a format that can help you answer common questions, like: |
| 17 | + |
| 18 | +- Are my builds sufficiently parallelized? |
| 19 | +- What should I include in my pre-compiled header (PCH)? |
| 20 | +- Is there a specific bottleneck I should focus on to increase my build speeds? |
| 21 | + |
| 22 | +The two main components of this technology are the command-line utility *vcperf.exe* and an add-in for the Windows Performance Analyzer (WPA) trace viewer. The utility is used to collect traces of your build, while the add-in allows you to view them in WPA. Follow these steps to get started using these two tools. |
| 23 | + |
| 24 | +## Step 1: Install and configure Windows Performance Analyzer |
| 25 | + |
| 26 | +WPA is a trace viewer available in the Windows Assessment and Deployment Kit (ADK). It's a separate utility that's not part of the components you can install with the Visual Studio installer. |
| 27 | + |
| 28 | +A version of WPA that supports C++ Build Insights is currently only available in the Windows ADK Insider Preview. To access this preview, you must sign up for the [Windows Insider program](https://insider.windows.com). You don't need to install the Windows 10 Insider Preview operating system to obtain the Windows ADK preview. You only need to register your Microsoft account with the Windows Insider Program. |
| 29 | + |
| 30 | +### To download and install WPA |
| 31 | + |
| 32 | +1. Browse to the Windows ADK Insider Preview [download page](https://www.microsoft.com/software-download/windowsinsiderpreviewADK). |
| 33 | + |
| 34 | +1. Download the Windows ADK Insider Preview. It's a disk image. |
| 35 | + |
| 36 | +1. Open the disk image and run the *adksetup.exe* installer. |
| 37 | + |
| 38 | +1. When prompted for the features that you want to install, select the **Windows Performance Toolkit**. You may select other features if you wish, but they're not required to install WPA. |
| 39 | + |
| 40 | +  |
| 41 | + |
| 42 | +### <a name="configuration-steps"></a> To configure Build Insights |
| 43 | + |
| 44 | +1. Launch WPA. |
| 45 | + |
| 46 | +1. Select **Window** > **Select Tables (Experimental)**. |
| 47 | + |
| 48 | +1. Scroll down to the **Diagnostics** section. |
| 49 | + |
| 50 | +1. Select all the MSVC Build Insights views. |
| 51 | + |
| 52 | +  |
| 53 | + |
| 54 | +## Step 2: Trace your build with vcperf.exe |
| 55 | + |
| 56 | +To view C++ Build Insights data, first collect it into a trace file by following these steps: |
| 57 | + |
| 58 | +1. Open a native tools or cross tools developer command prompt for Visual Studio 2019 in administrator mode. (Right-click the Start menu item and choose **More** > **Run as administrator**.) |
| 59 | + |
| 60 | +1. In the command prompt window, enter this command: |
| 61 | + |
| 62 | + **vcperf.exe /start _SessionName_** |
| 63 | + |
| 64 | + Choose a session name you'll remember for *SessionName*. |
| 65 | + |
| 66 | +1. Build your project as you normally would. You don't need to use the same command prompt window to build. |
| 67 | + |
| 68 | +1. In the command prompt window, enter this command: |
| 69 | + |
| 70 | + **vcperf.exe /stop _SessionName_ _traceFile.etl_** |
| 71 | + |
| 72 | + Use the same session name you chose for *SessionName* before. Choose an appropriate name for the *traceFile.etl* trace file. |
| 73 | + |
| 74 | +Here's what a typical *vcperf.exe* command sequence looks like in a developer command prompt window: |
| 75 | + |
| 76 | + |
| 77 | + |
| 78 | +### Important notes about vcperf.exe |
| 79 | + |
| 80 | +- Administrator privileges are required to start or stop a *vcperf.exe* trace. Use a developer command prompt window that you open by using **Run as administrator**. |
| 81 | + |
| 82 | +- Only one tracing session at a time may run on a machine. |
| 83 | + |
| 84 | +- Make sure to remember the session name you used to start your trace. It can be troublesome to stop a running session without knowing its name. |
| 85 | + |
| 86 | +- Just like *cl.exe* and *link.exe*, the command-line utility *vcperf.exe* is included in an MSVC installation. No additional steps are required to obtain this component. |
| 87 | + |
| 88 | +- *vcperf.exe* collects information about all MSVC tools running on your system. As a result, you don't have to start your build from the same command prompt you used to collect the trace. You can build your project from either a different command prompt, or even in Visual Studio. |
| 89 | + |
| 90 | +## Step 3: View your trace in Windows Performance Analyzer |
| 91 | + |
| 92 | +Launch WPA and open the trace you just collected. WPA should recognize it as a C++ Build Insights trace, and the following views should appear in the Graph Explorer panel on the left: |
| 93 | + |
| 94 | +- Build Explorer |
| 95 | +- Files |
| 96 | +- Function |
| 97 | + |
| 98 | +If you can't see these views, double-check that WPA is configured correctly, as described in [Step 1](#configuration-steps). You can view your build data by dragging the views into the empty Analysis window on the right, as shown here: |
| 99 | + |
| 100 | + |
| 101 | + |
| 102 | +Other views are available in the Graph Explorer panel. Drag them into the Analysis window when you're interested in the information they contain. A useful one is the CPU (Sampled) view, which shows CPU utilization throughout your build. |
| 103 | + |
| 104 | +## More information |
| 105 | + |
| 106 | +[Windows Performance Analyzer basics](wpa-basics.md)\ |
| 107 | +Learn about common WPA operations that can help you analyze your build traces. |
| 108 | + |
| 109 | +[vcperf.exe reference](vcperf-reference.md)\ |
| 110 | +The *vcperf.exe* command reference lists all the available command options. |
| 111 | + |
| 112 | +[Windows Performance Analyzer views reference](wpa-views-reference.md)\ |
| 113 | +Refer to this article for details about the C++ Build Insights views in WPA. |
| 114 | + |
| 115 | +[Windows Performance Analyzer](/windows-hardware/test/wpt/windows-performance-analyzer)\ |
| 116 | +The official WPA documentation site. |
| 117 | + |
| 118 | +::: moniker-end |
0 commit comments