11# !/usr/bin/env pwsh
22# Performance comparison script for Lua-RS vs Native Lua
33
4+ param (
5+ [switch ]$NoColor
6+ )
7+
48$benchmarks = @ (
59 " bench_arithmetic.lua" ,
610 " bench_functions.lua" ,
@@ -12,32 +16,45 @@ $benchmarks = @(
1216# Detect Native Lua executable
1317$nativeLua = if ($env: NATIVE_LUA ) { $env: NATIVE_LUA } else { " lua" }
1418
19+ # Helper function to write with optional color
20+ function Write-ColorHost {
21+ param (
22+ [string ]$Message ,
23+ [string ]$Color = " White"
24+ )
25+ if ($NoColor ) {
26+ Write-Host $Message
27+ } else {
28+ Write-Host $Message - ForegroundColor $Color
29+ }
30+ }
31+
1532Write-Host " "
16- Write-Host " ========================================" - ForegroundColor Cyan
17- Write-Host " Lua-RS vs Native Lua Performance" - ForegroundColor Cyan
18- Write-Host " ========================================" - ForegroundColor Cyan
19- Write-Host " Native Lua: $nativeLua " - ForegroundColor Gray
33+ Write-ColorHost " ========================================" " Cyan"
34+ Write-ColorHost " Lua-RS vs Native Lua Performance" " Cyan"
35+ Write-ColorHost " ========================================" " Cyan"
36+ Write-ColorHost " Native Lua: $nativeLua " " Gray"
2037Write-Host " "
2138
2239foreach ($bench in $benchmarks ) {
2340 Write-Host " "
24- Write-Host " >>> $bench <<<" - ForegroundColor Yellow
41+ Write-ColorHost " >>> $bench <<<" " Yellow"
2542 Write-Host " "
2643
27- Write-Host " --- Lua-RS ---" - ForegroundColor Magenta
44+ Write-ColorHost " --- Lua-RS ---" " Magenta"
2845 & " .\target\release\lua.exe" " benchmarks\$bench "
2946
3047 Write-Host " "
31- Write-Host " --- Native Lua ---" - ForegroundColor Green
48+ Write-ColorHost " --- Native Lua ---" " Green"
3249 & $nativeLua " benchmarks\$bench "
3350
3451 Write-Host " "
3552 Write-Host " ----------------------------------------"
3653}
3754
3855Write-Host " "
39- Write-Host " ========================================" - ForegroundColor Cyan
40- Write-Host " Comparison Complete!" - ForegroundColor Cyan
41- Write-Host " ========================================" - ForegroundColor Cyan
56+ Write-ColorHost " ========================================" " Cyan"
57+ Write-ColorHost " Comparison Complete!" " Cyan"
58+ Write-ColorHost " ========================================" " Cyan"
4259Write-Host " "
43- Write-Host " See PERFORMANCE_REPORT.md for detailed analysis" - ForegroundColor Yellow
60+ Write-ColorHost " See PERFORMANCE_REPORT.md for detailed analysis" " Yellow"
0 commit comments