-
Notifications
You must be signed in to change notification settings - Fork 0
311 lines (265 loc) · 12.6 KB
/
Copy pathperf-compare.yml
File metadata and controls
311 lines (265 loc) · 12.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
name: Performance Comparison
on:
workflow_dispatch:
push:
paths:
- 'main.cpp'
- '.github/workflows/perf-compare.yml'
pull_request:
paths:
- 'main.cpp'
- '.github/workflows/perf-compare.yml'
permissions:
contents: read
jobs:
perf-comparison:
runs-on: windows-latest
steps:
- name: Checkout this repo
uses: actions/checkout@v4
with:
path: win-witr-cpp
# Install pranshuparmar's witr (Go version)
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: 'stable'
- name: Clone and build pranshuparmar's witr
shell: pwsh
run: |
$ErrorActionPreference = "Stop"
git clone https://github.com/pranshuparmar/witr.git witr-go
cd witr-go
go build -o witr.exe
if ($LASTEXITCODE -ne 0) { exit 1 }
Write-Host "Built pranshuparmar's witr (Go version)"
.\witr.exe --version
# Install m-de-graaff's witr-win (Rust version)
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
# Note: Using @stable intentionally to test against latest Rust version
- name: Clone and build m-de-graaff's witr-win
continue-on-error: true
id: rust_build
shell: pwsh
run: |
$ErrorActionPreference = "Continue"
git clone https://github.com/m-de-graaff/witr-win.git witr-rust
cd witr-rust
cargo build --release 2>&1 | Out-Host
if ($LASTEXITCODE -ne 0) {
Write-Warning "Rust version failed to build - will be skipped in comparison"
exit 1
}
# The binary name is witr-win.exe, not witr.exe
if (Test-Path "target/release/witr-win.exe") {
Copy-Item "target/release/witr-win.exe" "../witr-rust.exe"
Write-Host "Built m-de-graaff's witr-win (Rust version)"
..\witr-rust.exe --version
} else {
Write-Warning "Rust binary not found - build may have failed"
exit 1
}
# Build this repo's win-witr (C++ version)
- name: Setup MSVC
uses: ilammy/msvc-dev-cmd@v1
- name: Compile win-witr
shell: pwsh
run: |
$ErrorActionPreference = "Stop"
cd win-witr-cpp
cl /O2 /GL /std:c++20 /EHsc main.cpp /DUNICODE /D_UNICODE /Fe:win-witr.exe
if ($LASTEXITCODE -ne 0) { exit 1 }
Write-Host "Built win-witr (C++ version)"
.\win-witr.exe --version
# Run performance comparison tests
- name: Run Performance Comparison
shell: pwsh
run: |
# Enable ANSI colors for win-witr C++ output
$env:force_ansi = 1
Write-Host ""
Write-Host "=====================================" -ForegroundColor Cyan
Write-Host "WITR PERFORMANCE COMPARISON" -ForegroundColor Cyan
Write-Host "=====================================" -ForegroundColor Cyan
Write-Host ""
# Add all executables to variables for easy access
$witrGo = "$PWD\witr-go\witr.exe"
$witrRust = "$PWD\witr-rust.exe"
$witrCpp = "$PWD\win-witr-cpp\win-witr.exe"
# Check which versions are available
$hasRust = Test-Path $witrRust
if (-not $hasRust) {
Write-Warning "Rust version not available - it failed to build. Comparison will only include Go and C++ versions."
Write-Host ""
}
# Test processes - use common Windows processes that should exist
$testProcesses = @(
"explorer",
"winlogon",
"lsass",
"csrss",
"services",
"svchost",
"smss",
"wininit",
"dwm",
"RuntimeBroker",
"SearchIndexer",
"spoolsv",
"taskhostw",
"fontdrvhost",
"conhost"
)
Write-Host "Testing process lookup performance on $($testProcesses.Count) processes" -ForegroundColor Yellow
Write-Host ""
# First, show sample output from each tool for svchost process
Write-Host "=====================================" -ForegroundColor Cyan
Write-Host "SAMPLE OUTPUT COMPARISON (svchost)" -ForegroundColor Cyan
Write-Host "=====================================" -ForegroundColor Cyan
Write-Host ""
Write-Host "--- Go version output ---" -ForegroundColor Green
& $witrGo svchost
Write-Host ""
if ($hasRust) {
Write-Host "--- Rust version output ---" -ForegroundColor Green
& $witrRust svchost
Write-Host ""
}
Write-Host "--- C++ version output ---" -ForegroundColor Green
& $witrCpp svchost
Write-Host ""
Write-Host ""
# Results storage
$results = @{
"Go" = @()
"Rust" = @()
"C++" = @()
}
# Run tests for each process
foreach ($process in $testProcesses) {
Write-Host "Testing: $process" -ForegroundColor White
Write-Host "----------------------------------------" -ForegroundColor Gray
# Test Go version
Write-Host " Go version:" -ForegroundColor Green -NoNewline
$goTime = Measure-Command { & $witrGo $process 2>&1 | Out-Null }
$goMs = [Math]::Round($goTime.TotalMilliseconds, 2)
Write-Host " $goMs ms" -ForegroundColor Cyan
$results["Go"] += $goMs
# Test Rust version (if available)
if ($hasRust) {
Write-Host " Rust version:" -ForegroundColor Green -NoNewline
$rustTime = Measure-Command { & $witrRust $process 2>&1 | Out-Null }
$rustMs = [Math]::Round($rustTime.TotalMilliseconds, 2)
Write-Host " $rustMs ms" -ForegroundColor Cyan
$results["Rust"] += $rustMs
}
# Test C++ version
Write-Host " C++ version:" -ForegroundColor Green -NoNewline
$cppTime = Measure-Command { & $witrCpp $process 2>&1 | Out-Null }
$cppMs = [Math]::Round($cppTime.TotalMilliseconds, 2)
Write-Host " $cppMs ms" -ForegroundColor Cyan
$results["C++"] += $cppMs
Write-Host ""
}
# Calculate and display totals
Write-Host ""
Write-Host "=====================================" -ForegroundColor Cyan
Write-Host "TOTAL RESULTS" -ForegroundColor Cyan
Write-Host "=====================================" -ForegroundColor Cyan
$goTotal = ($results["Go"] | Measure-Object -Sum).Sum
$rustTotal = if ($hasRust) { ($results["Rust"] | Measure-Object -Sum).Sum } else { 0 }
$cppTotal = ($results["C++"] | Measure-Object -Sum).Sum
Write-Host ""
Write-Host "Total time for $($testProcesses.Count) process lookups:" -ForegroundColor Yellow
Write-Host " Go (pranshuparmar/witr): $([Math]::Round($goTotal, 2)) ms" -ForegroundColor Green
if ($hasRust) {
Write-Host " Rust (m-de-graaff/witr-win): $([Math]::Round($rustTotal, 2)) ms" -ForegroundColor Green
} else {
Write-Host " Rust (m-de-graaff/witr-win): N/A (build failed)" -ForegroundColor Yellow
}
Write-Host " C++ (supervoidcoder/win-witr): $([Math]::Round($cppTotal, 2)) ms" -ForegroundColor Green
Write-Host ""
# Calculate averages
$goAvg = [Math]::Round($goTotal / $testProcesses.Count, 2)
$rustAvg = if ($hasRust) { [Math]::Round($rustTotal / $testProcesses.Count, 2) } else { 0 }
$cppAvg = [Math]::Round($cppTotal / $testProcesses.Count, 2)
Write-Host "Average time per lookup:" -ForegroundColor Yellow
Write-Host " Go: $goAvg ms" -ForegroundColor Green
if ($hasRust) {
Write-Host " Rust: $rustAvg ms" -ForegroundColor Green
}
Write-Host " C++: $cppAvg ms" -ForegroundColor Green
Write-Host ""
# Determine winner
$times = @{
"Go (pranshuparmar/witr)" = $goTotal
"C++ (supervoidcoder/win-witr)" = $cppTotal
}
if ($hasRust) {
$times["Rust (m-de-graaff/witr-win)"] = $rustTotal
}
$winner = $times.GetEnumerator() | Sort-Object Value | Select-Object -First 1
$slowest = $times.GetEnumerator() | Sort-Object Value -Descending | Select-Object -First 1
Write-Host "=====================================" -ForegroundColor Cyan
Write-Host "🏆 FASTEST: $($winner.Name)" -ForegroundColor Green
Write-Host "🐌 SLOWEST: $($slowest.Name)" -ForegroundColor Red
Write-Host "=====================================" -ForegroundColor Cyan
Write-Host ""
# Calculate speed differences using times instead of percentages
Write-Host "Performance comparison:" -ForegroundColor Yellow
# C++ vs Go
if ($cppTotal -gt 0 -and $goTotal -gt 0) {
$cppVsGoTimes = [Math]::Round($goTotal / $cppTotal, 1)
if ($cppVsGoTimes -ge 1.1) {
Write-Host " C++ is $($cppVsGoTimes)x faster than Go" -ForegroundColor Green
} elseif ($cppVsGoTimes -le 0.9) {
$goVsCppTimes = [Math]::Round($cppTotal / $goTotal, 1)
Write-Host " Go is $($goVsCppTimes)x faster than C++" -ForegroundColor Red
} else {
Write-Host " C++ and Go have similar performance" -ForegroundColor Yellow
}
}
# C++ vs Rust
if ($hasRust -and $cppTotal -gt 0 -and $rustTotal -gt 0) {
$cppVsRustTimes = [Math]::Round($rustTotal / $cppTotal, 1)
if ($cppVsRustTimes -ge 1.1) {
Write-Host " C++ is $($cppVsRustTimes)x faster than Rust" -ForegroundColor Green
} elseif ($cppVsRustTimes -le 0.9) {
$rustVsCppTimes = [Math]::Round($cppTotal / $rustTotal, 1)
Write-Host " Rust is $($rustVsCppTimes)x faster than C++" -ForegroundColor Red
} else {
Write-Host " C++ and Rust have similar performance" -ForegroundColor Yellow
}
}
Write-Host ""
# Also test --version and --help commands for completeness
Write-Host "=====================================" -ForegroundColor Cyan
Write-Host "COMMAND PERFORMANCE TESTS" -ForegroundColor Cyan
Write-Host "=====================================" -ForegroundColor Cyan
Write-Host ""
# Test --version
Write-Host "Testing --version command:" -ForegroundColor Yellow
$goVersionTime = Measure-Command { & $witrGo --version | Out-Null }
Write-Host " Go: $([Math]::Round($goVersionTime.TotalMilliseconds, 2)) ms" -ForegroundColor Green
if ($hasRust) {
$rustVersionTime = Measure-Command { & $witrRust --version | Out-Null }
Write-Host " Rust: $([Math]::Round($rustVersionTime.TotalMilliseconds, 2)) ms" -ForegroundColor Green
}
$cppVersionTime = Measure-Command { & $witrCpp --version | Out-Null }
Write-Host " C++: $([Math]::Round($cppVersionTime.TotalMilliseconds, 2)) ms" -ForegroundColor Green
Write-Host ""
# Test --help
Write-Host "Testing --help command:" -ForegroundColor Yellow
$goHelpTime = Measure-Command { & $witrGo --help | Out-Null }
Write-Host " Go: $([Math]::Round($goHelpTime.TotalMilliseconds, 2)) ms" -ForegroundColor Green
if ($hasRust) {
$rustHelpTime = Measure-Command { & $witrRust --help | Out-Null }
Write-Host " Rust: $([Math]::Round($rustHelpTime.TotalMilliseconds, 2)) ms" -ForegroundColor Green
}
$cppHelpTime = Measure-Command { & $witrCpp --help | Out-Null }
Write-Host " C++: $([Math]::Round($cppHelpTime.TotalMilliseconds, 2)) ms" -ForegroundColor Green
Write-Host ""
Write-Host "=====================================" -ForegroundColor Cyan
Write-Host "Performance comparison complete!" -ForegroundColor Cyan
Write-Host "=====================================" -ForegroundColor Cyan