bench: tools/bench.sh core [filter] runs tools/bench_core.luau under luau -O2, --codegen and LuaJIT

This commit is contained in:
4DBug committed 2026-11-01 19:58:07 -06:00
1 parent 53290f0e0c
commit 6fab0d3dca
2 files changed
+15 -2

No files matched your search

+12 -2
View File
@@ -1,9 +1,19 @@
#!/usr/bin/env bash
# Timings (bash tools/bench.sh): tools/bench.luau under luau --codegen -O2 and under LuaJIT (the module build, build/_modules/luajit).
# Timings (bash tools/bench.sh [core [filter]]): tools/bench.luau under luau --codegen -O2 and under LuaJIT (the module build,
# build/_modules/luajit). "core" runs tools/bench_core.luau (inflate / deflate, checksums, rbxm / rbxmx, json / xml,
# F.detect, gltf / obj, the other decompressors) under luau -O2, luau --codegen -O2 and LuaJIT; a filter keeps the lines
# whose label contains it.
cd "$(dirname "$0")/.." || exit 1
LUAU=${LUAU:-$(command -v luau || nix shell nixpkgs#luau -c sh -c 'command -v luau')}
LUAJIT=${LUAJIT:-$(command -v luajit || nix shell nixpkgs#luajit -c sh -c 'command -v luajit')}
python3 -I tools/fixtures.py > /dev/null || exit 1
python3 -I tools/build.py luajit > /dev/null || exit 1
LJPATH='package.path = "build/_modules/luajit/?.lua;build/_modules/luajit/?/init.lua;" .. package.path'
if [ "$1" = core ]; then
"$LUAU" -O2 tools/bench_core.luau -a "$2"
"$LUAU" --codegen -O2 tools/bench_core.luau -a "$2"
"$LUAJIT" -e "$LJPATH" build/_modules/luajit/tools/bench_core.lua "$2"
exit 0
fi
"$LUAU" --codegen -O2 tools/bench.luau
"$LUAJIT" -e 'package.path = "build/_modules/luajit/?.lua;build/_modules/luajit/?/init.lua;" .. package.path' build/_modules/luajit/tools/bench.lua
"$LUAJIT" -e "$LJPATH" build/_modules/luajit/tools/bench.lua
+3
View File
@@ -11,6 +11,9 @@ local B = require("@tests/gen/deflate_bench")
local runtime = if (_G :: any).jit ~= nil then "luajit" else "luau"
local filter: string? = (...) :: any
if filter == "" then
filter = nil
end
local function want(labels: string): boolean
return filter == nil or string.find(labels, filter :: string, 1, true) ~= nil