Skip to content

Commit e716fd9

Browse files
committed
update ci
1 parent ce29a6d commit e716fd9

File tree

3 files changed

+56
-20
lines changed

3 files changed

+56
-20
lines changed

.github/workflows/benchmarks.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jobs:
4949
echo "" >> $GITHUB_STEP_SUMMARY
5050
echo '```' >> $GITHUB_STEP_SUMMARY
5151
chmod +x run_benchmarks.sh
52-
./run_benchmarks.sh 2>&1 | tee -a $GITHUB_STEP_SUMMARY
52+
./run_benchmarks.sh --nocolor 2>&1 | tee -a $GITHUB_STEP_SUMMARY
5353
echo '```' >> $GITHUB_STEP_SUMMARY
5454
5555
benchmark-windows:
@@ -98,7 +98,7 @@ jobs:
9898
echo '```' >> $env:GITHUB_STEP_SUMMARY
9999
# Use the lua we built
100100
$env:NATIVE_LUA = "$env:GITHUB_WORKSPACE\lua_bin\lua.exe"
101-
.\run_benchmarks.ps1 2>&1 | Tee-Object -Append -FilePath $env:GITHUB_STEP_SUMMARY
101+
.\run_benchmarks.ps1 -NoColor 2>&1 | Tee-Object -Append -FilePath $env:GITHUB_STEP_SUMMARY
102102
echo '```' >> $env:GITHUB_STEP_SUMMARY
103103
104104
benchmark-macos:
@@ -139,5 +139,5 @@ jobs:
139139
echo "" >> $GITHUB_STEP_SUMMARY
140140
echo '```' >> $GITHUB_STEP_SUMMARY
141141
chmod +x run_benchmarks.sh
142-
./run_benchmarks.sh 2>&1 | tee -a $GITHUB_STEP_SUMMARY
142+
./run_benchmarks.sh --nocolor 2>&1 | tee -a $GITHUB_STEP_SUMMARY
143143
echo '```' >> $GITHUB_STEP_SUMMARY

run_benchmarks.ps1

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
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+
1532
Write-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"
2037
Write-Host ""
2138

2239
foreach ($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

3855
Write-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"
4259
Write-Host ""
43-
Write-Host "See PERFORMANCE_REPORT.md for detailed analysis" -ForegroundColor Yellow
60+
Write-ColorHost "See PERFORMANCE_REPORT.md for detailed analysis" "Yellow"

run_benchmarks.sh

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,31 @@ BENCHMARKS=(
1111
"bench_control_flow.lua"
1212
)
1313

14-
# Colors
15-
CYAN='\033[0;36m'
16-
YELLOW='\033[1;33m'
17-
MAGENTA='\033[0;35m'
18-
GREEN='\033[0;32m'
19-
NC='\033[0m' # No Color
14+
# Parse arguments
15+
NOCOLOR=false
16+
for arg in "$@"; do
17+
case $arg in
18+
--nocolor|-n)
19+
NOCOLOR=true
20+
shift
21+
;;
22+
esac
23+
done
24+
25+
# Colors (disabled with --nocolor)
26+
if [ "$NOCOLOR" = true ]; then
27+
CYAN=''
28+
YELLOW=''
29+
MAGENTA=''
30+
GREEN=''
31+
NC=''
32+
else
33+
CYAN='\033[0;36m'
34+
YELLOW='\033[1;33m'
35+
MAGENTA='\033[0;35m'
36+
GREEN='\033[0;32m'
37+
NC='\033[0m'
38+
fi
2039

2140
echo ""
2241
echo -e "${CYAN}========================================${NC}"

0 commit comments

Comments
 (0)