Skip to content

Commit c648f39

Browse files
authored
Merge pull request #885 from wesleywiser/hardware_counters_windows
Support collecting hardware performance counters on Windows
2 parents 7076c93 + 5384e7d commit c648f39

File tree

5 files changed

+1150
-66
lines changed

5 files changed

+1150
-66
lines changed

collector/README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,39 @@ If you've collected new data, you can run `curl -X POST
156156
localhost:2346/perf/onpush` to update the site's view of the data, or just
157157
restart the server.
158158

159+
### Benchmarking on Windows
160+
161+
To benchmark on Windows, you will need to run the collector in a elevated context
162+
so that it can access the hardware performance counters. Note: some virtualized
163+
environments do not permit access to these counters for guest VMs.
164+
165+
You will also need to provide the paths to the xperf and tracelog tools (or have them
166+
available on your PATH). Some common paths to these tools look like:
167+
168+
```pwsh
169+
$env:XPERF="C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit\xperf.exe"
170+
$env:TRACELOG="C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x64\tracelog.exe"
171+
```
172+
173+
Finally, while most of the options you can pass to the collector are supported, the majority of
174+
the profilers used in the `profile_local` command are not. In Windows, the only currently supported
175+
profiler is the `self-profiler`.
176+
177+
As a complete example, let's run just the `regex` benchmark in the `Debug` build with
178+
self-profiling results available:
179+
180+
```pwsh
181+
$env:XPERF="C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit\xperf.exe"
182+
$env:TRACELOG="C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x64\tracelog.exe"
183+
.\target\release\collector.exe bench_local $env:RUST_ORIGINAL Original --builds Debug --include regex --self-profile
184+
.\target\release\collector.exe bench_local $env:RUST_MODIFIED Modified --builds Debug --include regex --self-profile
185+
.\target\release\site.exe .\results.db
186+
```
187+
188+
The open a web browser to `http://localhost:2346/compare.html?start=Original&end=Modified&stat=instructions%3Au`.
189+
190+
Note: This example uses Powershell syntax.
191+
159192
### Technical details of the benchmark server
160193

161194
We download the artifacts (rustc, rust-std, cargo) produced by CI and properly

0 commit comments

Comments
 (0)