Skip to content

Commit a24317e

Browse files
committed
Tech review of PGO in Windows
1 parent 1ff5051 commit a24317e

4 files changed

Lines changed: 19 additions & 18 deletions

File tree

content/learning-paths/laptops-and-desktops/win_profile_guided_optimisation/_index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ learning_objectives:
1616

1717
prerequisites:
1818
- Basic C++ understanding.
19-
- A Windows on Arm machine with [Visual Studio 2022](/install-guides/vs-woa/) and the C++ desktop development workload installed.
19+
- A Windows on Arm machine with [Visual Studio](/install-guides/vs-woa/) and the C++ desktop development tools installed.
2020

2121
author: Tom Dunkle
2222

content/learning-paths/laptops-and-desktops/win_profile_guided_optimisation/how-to-2.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Before you start working with Profile-Guided Optimization, you need to understan
1010

1111
Google Benchmark is a C++ library specifically designed for microbenchmarking, which means measuring the performance of small code snippets with high accuracy. Microbenchmarking helps you identify bottlenecks and optimize critical sections, especially in performance-sensitive applications.
1212

13-
Google Benchmark simplifies this process by providing a framework that manages iterations, times execution, and performs statistical analysis. This lets you focus on the code being measured, rather than writing boilerplate or trying to prevent unwanted compiler optimizations manually.
13+
Google Benchmark simplifies this process by providing a framework that manages iterations, times execution, and performs statistical analysis. This lets you focus on the code being measured, rather than writing test code or trying to prevent unwanted compiler optimizations manually.
1414

1515
To use Google Benchmark, you define a function that accepts a `benchmark::State&` parameter and iterate over it to perform the benchmarking. You register the function using the `BENCHMARK` macro and include `BENCHMARK_MAIN()` to generate the benchmark's entry point.
1616

content/learning-paths/laptops-and-desktops/win_profile_guided_optimisation/how-to-3.md

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,18 @@ For this example, you'll use an Arm computer running Windows.
1414

1515
## Install the required tools
1616

17-
First, you need to install Google Benchmark for Arm64 via vcpkg. Run the following commands in PowerShell as Administrator:
17+
### Install vcpkg and Google Benchmark
18+
19+
Run the following commands in PowerShell:
1820

1921
```console
20-
cd C:\git
21-
git clone https://github.com/microsoft/vcpkg.git
22-
cd vcpkg
23-
.\bootstrap-vcpkg.bat
24-
.\vcpkg install benchmark:arm64-windows-static
22+
iex (iwr -useb https://aka.ms/vcpkg-init.ps1)
23+
cd $HOME
24+
mkdir pgo-benchmark
25+
cd pgo-benchmark
26+
& "$HOME\.vcpkg\vcpkg.exe" new --application
27+
& "$HOME\.vcpkg\vcpkg.exe" add port benchmark
28+
& "$HOME\.vcpkg\vcpkg.exe" install
2529
```
2630

2731
## Create the division benchmark
@@ -52,21 +56,24 @@ BENCHMARK_MAIN();
5256
5357
## Compile and run the baseline benchmark
5458
59+
Open an **ARM64 Native Tools Command Prompt** from the Start menu, then type `powershell` to start PowerShell with the ARM64 compiler environment.
60+
5561
Before compiling, set an environment variable to refer to the vcpkg installation directory:
5662
5763
```console
58-
$VCPKG="C:\git\vcpkg\installed\arm64-windows-static"
64+
$VCPKG="$HOME\pgo-benchmark\vcpkg_installed\arm64-windows"
5965
```
6066

6167
Now compile the benchmark. This command uses the MSVC compiler and links with the Google Benchmark libraries:
6268

6369
```console
64-
cl /D BENCHMARK_STATIC_DEFINE div_bench.cpp /link /LIBPATH:"$VCPKG\lib" benchmark.lib benchmark_main.lib shlwapi.lib
70+
cl /I"$VCPKG\include" /D BENCHMARK_STATIC_DEFINE div_bench.cpp /link /LIBPATH:"$VCPKG\lib" benchmark.lib benchmark_main.lib shlwapi.lib
6571
```
6672

6773
Run the program to establish your baseline performance:
6874

6975
```console
76+
$env:PATH += ";$HOME\pgo-benchmark\vcpkg_installed\arm64-windows\bin"
7077
.\div_bench.exe
7178
```
7279

content/learning-paths/laptops-and-desktops/win_profile_guided_optimisation/how-to-4.md

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,12 @@ Now that you have a baseline benchmark, you're ready to apply Profile-Guided Opt
1010

1111
## Build the instrumented binary
1212

13-
First, open the Arm developer shell so the compiler is in your PATH:
14-
15-
```console
16-
& "C:\Program Files\Microsoft Visual Studio\18\Community\Common7\Tools\Launch-VsDevShell.ps1" -Arch arm64
17-
```
18-
19-
You may need to change the version number in your Visual Studio path, depending on which version you've installed.
13+
You should already have an ARM64 Native Tools Command Prompt open with PowerShell running from the previous section.
2014

2115
Set the environment variable to refer to the vcpkg installation directory:
2216

2317
```console
24-
$VCPKG="C:\git\vcpkg\installed\arm64-windows-static"
18+
$VCPKG="$HOME\pgo-benchmark\vcpkg_installed\arm64-windows"
2519
```
2620

2721
Build the instrumented binary with the `/GENPROFILE` flag. This creates a version of your program that records how it executes:

0 commit comments

Comments
 (0)