Skip to content

Commit d4c43b6

Browse files
Fix Rust witr-win build issues - handle build failures gracefully
Co-authored-by: supervoidcoder <88671013+supervoidcoder@users.noreply.github.com>
1 parent 99e366e commit d4c43b6

1 file changed

Lines changed: 68 additions & 32 deletions

File tree

.github/workflows/perf-compare.yml

Lines changed: 68 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,27 @@ jobs:
4646
# Note: Using @stable intentionally to test against latest Rust version
4747

4848
- name: Clone and build m-de-graaff's witr-win
49+
continue-on-error: true
50+
id: rust_build
4951
shell: pwsh
5052
run: |
51-
$ErrorActionPreference = "Stop"
53+
$ErrorActionPreference = "Continue"
5254
git clone https://github.com/m-de-graaff/witr-win.git witr-rust
5355
cd witr-rust
54-
cargo build --release
55-
if ($LASTEXITCODE -ne 0) { exit 1 }
56-
Copy-Item "target/release/witr.exe" "witr-rust.exe"
57-
Write-Host "Built m-de-graaff's witr-win (Rust version)"
58-
.\witr-rust.exe --version
56+
cargo build --release 2>&1 | Out-Host
57+
if ($LASTEXITCODE -ne 0) {
58+
Write-Warning "Rust version failed to build - will be skipped in comparison"
59+
exit 1
60+
}
61+
# The binary name is witr-win.exe, not witr.exe
62+
if (Test-Path "target/release/witr-win.exe") {
63+
Copy-Item "target/release/witr-win.exe" "../witr-rust.exe"
64+
Write-Host "Built m-de-graaff's witr-win (Rust version)"
65+
..\witr-rust.exe --version
66+
} else {
67+
Write-Warning "Rust binary not found - build may have failed"
68+
exit 1
69+
}
5970
6071
# Build this repo's win-witr (C++ version)
6172
- name: Setup MSVC
@@ -86,6 +97,13 @@ jobs:
8697
$witrRust = "$PWD\witr-rust.exe"
8798
$witrCpp = "$PWD\win-witr-cpp\win-witr.exe"
8899
100+
# Check which versions are available
101+
$hasRust = Test-Path $witrRust
102+
if (-not $hasRust) {
103+
Write-Warning "Rust version not available - it failed to build. Comparison will only include Go and C++ versions."
104+
Write-Host ""
105+
}
106+
89107
# Test processes - use common Windows processes that should exist
90108
$testProcesses = @(
91109
"explorer",
@@ -109,9 +127,11 @@ jobs:
109127
& $witrGo explorer
110128
Write-Host ""
111129
112-
Write-Host "--- Rust version output ---" -ForegroundColor Green
113-
& $witrRust explorer
114-
Write-Host ""
130+
if ($hasRust) {
131+
Write-Host "--- Rust version output ---" -ForegroundColor Green
132+
& $witrRust explorer
133+
Write-Host ""
134+
}
115135
116136
Write-Host "--- C++ version output ---" -ForegroundColor Green
117137
& $witrCpp explorer
@@ -137,12 +157,14 @@ jobs:
137157
Write-Host " $goMs ms" -ForegroundColor Cyan
138158
$results["Go"] += $goMs
139159
140-
# Test Rust version
141-
Write-Host " Rust version:" -ForegroundColor Green -NoNewline
142-
$rustTime = Measure-Command { & $witrRust $process 2>&1 | Out-Null }
143-
$rustMs = [Math]::Round($rustTime.TotalMilliseconds, 2)
144-
Write-Host " $rustMs ms" -ForegroundColor Cyan
145-
$results["Rust"] += $rustMs
160+
# Test Rust version (if available)
161+
if ($hasRust) {
162+
Write-Host " Rust version:" -ForegroundColor Green -NoNewline
163+
$rustTime = Measure-Command { & $witrRust $process 2>&1 | Out-Null }
164+
$rustMs = [Math]::Round($rustTime.TotalMilliseconds, 2)
165+
Write-Host " $rustMs ms" -ForegroundColor Cyan
166+
$results["Rust"] += $rustMs
167+
}
146168
147169
# Test C++ version
148170
Write-Host " C++ version:" -ForegroundColor Green -NoNewline
@@ -161,33 +183,41 @@ jobs:
161183
Write-Host "=====================================" -ForegroundColor Cyan
162184
163185
$goTotal = ($results["Go"] | Measure-Object -Sum).Sum
164-
$rustTotal = ($results["Rust"] | Measure-Object -Sum).Sum
186+
$rustTotal = if ($hasRust) { ($results["Rust"] | Measure-Object -Sum).Sum } else { 0 }
165187
$cppTotal = ($results["C++"] | Measure-Object -Sum).Sum
166188
167189
Write-Host ""
168190
Write-Host "Total time for $($testProcesses.Count) process lookups:" -ForegroundColor Yellow
169-
Write-Host " Go (pranshuparmar/witr): $([Math]::Round($goTotal, 2)) ms" -ForegroundColor Green
170-
Write-Host " Rust (m-de-graaff/witr-win): $([Math]::Round($rustTotal, 2)) ms" -ForegroundColor Green
191+
Write-Host " Go (pranshuparmar/witr): $([Math]::Round($goTotal, 2)) ms" -ForegroundColor Green
192+
if ($hasRust) {
193+
Write-Host " Rust (m-de-graaff/witr-win): $([Math]::Round($rustTotal, 2)) ms" -ForegroundColor Green
194+
} else {
195+
Write-Host " Rust (m-de-graaff/witr-win): N/A (build failed)" -ForegroundColor Yellow
196+
}
171197
Write-Host " C++ (supervoidcoder/win-witr): $([Math]::Round($cppTotal, 2)) ms" -ForegroundColor Green
172198
Write-Host ""
173199
174200
# Calculate averages
175201
$goAvg = [Math]::Round($goTotal / $testProcesses.Count, 2)
176-
$rustAvg = [Math]::Round($rustTotal / $testProcesses.Count, 2)
202+
$rustAvg = if ($hasRust) { [Math]::Round($rustTotal / $testProcesses.Count, 2) } else { 0 }
177203
$cppAvg = [Math]::Round($cppTotal / $testProcesses.Count, 2)
178204
179205
Write-Host "Average time per lookup:" -ForegroundColor Yellow
180206
Write-Host " Go: $goAvg ms" -ForegroundColor Green
181-
Write-Host " Rust: $rustAvg ms" -ForegroundColor Green
207+
if ($hasRust) {
208+
Write-Host " Rust: $rustAvg ms" -ForegroundColor Green
209+
}
182210
Write-Host " C++: $cppAvg ms" -ForegroundColor Green
183211
Write-Host ""
184212
185213
# Determine winner
186214
$times = @{
187215
"Go (pranshuparmar/witr)" = $goTotal
188-
"Rust (m-de-graaff/witr-win)" = $rustTotal
189216
"C++ (supervoidcoder/win-witr)" = $cppTotal
190217
}
218+
if ($hasRust) {
219+
$times["Rust (m-de-graaff/witr-win)"] = $rustTotal
220+
}
191221
192222
$winner = $times.GetEnumerator() | Sort-Object Value | Select-Object -First 1
193223
$slowest = $times.GetEnumerator() | Sort-Object Value -Descending | Select-Object -First 1
@@ -200,7 +230,6 @@ jobs:
200230
201231
# Calculate speed differences
202232
$cppVsGo = [Math]::Round((($goTotal - $cppTotal) / $goTotal) * 100, 1)
203-
$cppVsRust = [Math]::Round((($rustTotal - $cppTotal) / $rustTotal) * 100, 1)
204233
205234
Write-Host "Performance comparison:" -ForegroundColor Yellow
206235
if ($cppVsGo -gt 0) {
@@ -211,12 +240,15 @@ jobs:
211240
Write-Host " C++ and Go have equal performance" -ForegroundColor Yellow
212241
}
213242
214-
if ($cppVsRust -gt 0) {
215-
Write-Host " C++ is $cppVsRust% faster than Rust" -ForegroundColor Green
216-
} elseif ($cppVsRust -lt 0) {
217-
Write-Host " C++ is $([Math]::Abs($cppVsRust))% slower than Rust" -ForegroundColor Red
218-
} else {
219-
Write-Host " C++ and Rust have equal performance" -ForegroundColor Yellow
243+
if ($hasRust) {
244+
$cppVsRust = [Math]::Round((($rustTotal - $cppTotal) / $rustTotal) * 100, 1)
245+
if ($cppVsRust -gt 0) {
246+
Write-Host " C++ is $cppVsRust% faster than Rust" -ForegroundColor Green
247+
} elseif ($cppVsRust -lt 0) {
248+
Write-Host " C++ is $([Math]::Abs($cppVsRust))% slower than Rust" -ForegroundColor Red
249+
} else {
250+
Write-Host " C++ and Rust have equal performance" -ForegroundColor Yellow
251+
}
220252
}
221253
Write-Host ""
222254
@@ -232,8 +264,10 @@ jobs:
232264
$goVersionTime = Measure-Command { & $witrGo --version | Out-Null }
233265
Write-Host " Go: $([Math]::Round($goVersionTime.TotalMilliseconds, 2)) ms" -ForegroundColor Green
234266
235-
$rustVersionTime = Measure-Command { & $witrRust --version | Out-Null }
236-
Write-Host " Rust: $([Math]::Round($rustVersionTime.TotalMilliseconds, 2)) ms" -ForegroundColor Green
267+
if ($hasRust) {
268+
$rustVersionTime = Measure-Command { & $witrRust --version | Out-Null }
269+
Write-Host " Rust: $([Math]::Round($rustVersionTime.TotalMilliseconds, 2)) ms" -ForegroundColor Green
270+
}
237271
238272
$cppVersionTime = Measure-Command { & $witrCpp --version | Out-Null }
239273
Write-Host " C++: $([Math]::Round($cppVersionTime.TotalMilliseconds, 2)) ms" -ForegroundColor Green
@@ -245,8 +279,10 @@ jobs:
245279
$goHelpTime = Measure-Command { & $witrGo --help | Out-Null }
246280
Write-Host " Go: $([Math]::Round($goHelpTime.TotalMilliseconds, 2)) ms" -ForegroundColor Green
247281
248-
$rustHelpTime = Measure-Command { & $witrRust --help | Out-Null }
249-
Write-Host " Rust: $([Math]::Round($rustHelpTime.TotalMilliseconds, 2)) ms" -ForegroundColor Green
282+
if ($hasRust) {
283+
$rustHelpTime = Measure-Command { & $witrRust --help | Out-Null }
284+
Write-Host " Rust: $([Math]::Round($rustHelpTime.TotalMilliseconds, 2)) ms" -ForegroundColor Green
285+
}
250286
251287
$cppHelpTime = Measure-Command { & $witrCpp --help | Out-Null }
252288
Write-Host " C++: $([Math]::Round($cppHelpTime.TotalMilliseconds, 2)) ms" -ForegroundColor Green

0 commit comments

Comments
 (0)