-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrun_benchmarks.ps1
More file actions
95 lines (75 loc) · 2.35 KB
/
run_benchmarks.ps1
File metadata and controls
95 lines (75 loc) · 2.35 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
#!/usr/bin/env pwsh
# Performance comparison script for Lua-RS vs Native Lua
param(
[switch]$NoColor
)
$benchmarks = @(
"bench_arithmetic.lua",
"bench_control_flow.lua",
"bench_locals.lua",
"bench_functions.lua",
"bench_closures.lua",
"bench_multiret.lua",
"bench_tables.lua",
"bench_table_lib.lua",
"bench_iterators.lua",
"bench_strings.lua",
"bench_string_lib.lua",
"bench_math.lua",
"bench_metatables.lua",
"bench_oop.lua",
"bench_coroutines.lua",
"bench_errors.lua"
)
# Detect Native Lua executable
$nativeLua = if ($env:NATIVE_LUA) { $env:NATIVE_LUA } else { "lua" }
# Helper function to write with optional color
function Write-ColorHost {
param(
[string]$Message,
[string]$Color = "White"
)
if ($NoColor) {
Write-Output $Message
} else {
Write-Host $Message -ForegroundColor $Color
}
}
function Invoke-BenchmarkRuntime {
param(
[string]$Executable,
[string]$ScriptPath
)
$output = & $Executable $ScriptPath 2>&1
$exitCode = $LASTEXITCODE
if ($exitCode -ne 0) {
throw "Benchmark failed for $ScriptPath with exit code $exitCode`n$($output | Out-String)"
}
foreach ($line in @($output)) {
Write-Output $line
}
}
Write-Output ""
Write-ColorHost "========================================" "Cyan"
Write-ColorHost " Lua-RS vs Native Lua Performance" "Cyan"
Write-ColorHost "========================================" "Cyan"
Write-ColorHost "Native Lua: $nativeLua" "Gray"
Write-Output ""
foreach ($bench in $benchmarks) {
Write-Output ""
Write-ColorHost ">>> $bench <<<" "Yellow"
Write-Output ""
Write-ColorHost "--- Lua-RS ---" "Magenta"
Invoke-BenchmarkRuntime -Executable ".\target\release\lua.exe" -ScriptPath "benchmarks\$bench"
Write-Output ""
Write-ColorHost "--- Native Lua ---" "Green"
Invoke-BenchmarkRuntime -Executable $nativeLua -ScriptPath "benchmarks\$bench"
Write-Output ""
Write-Output "----------------------------------------"
}
Write-Output ""
Write-ColorHost "========================================" "Cyan"
Write-ColorHost " Comparison Complete!" "Cyan"
Write-ColorHost "========================================" "Cyan"
Write-Output ""
Write-ColorHost "See PERFORMANCE_REPORT.md for detailed analysis" "Yellow"