Skip to content

Commit f89cf6a

Browse files
Fix performance comparison logic and address code review feedback
- Fixed comparison logic: when other tool is faster, say "Go is Nx faster" instead of "C++ is Nx slower" - Changed threshold from exact equality to ±10% for "similar performance" - Added safety checks for division by zero - More intuitive and grammatically correct output Co-authored-by: supervoidcoder <88671013+supervoidcoder@users.noreply.github.com>
1 parent 9b86fbc commit f89cf6a

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

.github/workflows/perf-compare.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -244,28 +244,28 @@ jobs:
244244
Write-Host "Performance comparison:" -ForegroundColor Yellow
245245
246246
# C++ vs Go
247-
if ($cppTotal -gt 0) {
247+
if ($cppTotal -gt 0 -and $goTotal -gt 0) {
248248
$cppVsGoTimes = [Math]::Round($goTotal / $cppTotal, 1)
249-
if ($cppVsGoTimes -gt 1) {
249+
if ($cppVsGoTimes -ge 1.1) {
250250
Write-Host " C++ is $($cppVsGoTimes)x faster than Go" -ForegroundColor Green
251-
} elseif ($cppVsGoTimes -lt 1) {
251+
} elseif ($cppVsGoTimes -le 0.9) {
252252
$goVsCppTimes = [Math]::Round($cppTotal / $goTotal, 1)
253-
Write-Host " C++ is $($goVsCppTimes)x slower than Go" -ForegroundColor Red
253+
Write-Host " Go is $($goVsCppTimes)x faster than C++" -ForegroundColor Red
254254
} else {
255-
Write-Host " C++ and Go have equal performance" -ForegroundColor Yellow
255+
Write-Host " C++ and Go have similar performance" -ForegroundColor Yellow
256256
}
257257
}
258258
259259
# C++ vs Rust
260-
if ($hasRust -and $cppTotal -gt 0) {
260+
if ($hasRust -and $cppTotal -gt 0 -and $rustTotal -gt 0) {
261261
$cppVsRustTimes = [Math]::Round($rustTotal / $cppTotal, 1)
262-
if ($cppVsRustTimes -gt 1) {
262+
if ($cppVsRustTimes -ge 1.1) {
263263
Write-Host " C++ is $($cppVsRustTimes)x faster than Rust" -ForegroundColor Green
264-
} elseif ($cppVsRustTimes -lt 1) {
264+
} elseif ($cppVsRustTimes -le 0.9) {
265265
$rustVsCppTimes = [Math]::Round($cppTotal / $rustTotal, 1)
266-
Write-Host " C++ is $($rustVsCppTimes)x slower than Rust" -ForegroundColor Red
266+
Write-Host " Rust is $($rustVsCppTimes)x faster than C++" -ForegroundColor Red
267267
} else {
268-
Write-Host " C++ and Rust have equal performance" -ForegroundColor Yellow
268+
Write-Host " C++ and Rust have similar performance" -ForegroundColor Yellow
269269
}
270270
}
271271
Write-Host ""

0 commit comments

Comments
 (0)