Files
sindoring d1961e79fc Sync upstream through b2473e60 and retain ruRU (#8)
Integrate 182 upstream commits through b2473e60 while retaining MoonWell packaging, branding and the community ruRU pack.

Upstream replaces the C Lua/mlua host with benilla-lua/benilla-mlua and the native glue screens with stock GlueXML. The update also includes the new locale/DBC/name rules, cache and interaction handling, rendering, quest log and chat behavior, including the latest quest completion and timed-quest failure fixes. Fork adaptations use the new APIs: stock Wow.ini locales remain intact, while the ruRU overlay reads column zero and retains its ruRU authentication tag and Lua identity. Russian names keep their twelve-letter policy and Unicode roster matching; fonts, spell costs, race/class labels and translated options retain real-pack regression coverage.

Windows regression fixes keep the locale-default test valid under instrumented window overrides and the shader assertion independent of checkout line endings. The original C Lua 5.1 host, rebuilt from c0630f3d in an isolated directory, reproduces the complete Windows cos-sweep answer byte for byte; cos now uses platform-specific goldens.

Validation on Windows: scripts/gates.sh passed all automatic gates, including real-data and no-install workspace tests, reference tables, documentation, message catalog, render-pass lint, player clippy/tests and engine boots with and without data. MoonWell player clippy also passed with -D warnings. The committed tree exactly matches the full green stamp; five vendored Kira files retain the tested checkout's line endings, with normalized contents unchanged. All three actual ruRU pack regressions passed in both builds. Fifteen test archives were restored read-only from the published client and SHA-256 checked.

Each real-data/player rung skipped 31 tests because the optional addon corpus is absent (24 general, 7 Quiver). Live smoke was not run: no declared probe account; no player-account login or character creation was performed. Linux/macOS changes were not locally built.
2026-10-17 21:10:31 +03:00

67 lines
3.3 KiB
Rust

//! Times each workload in this interpreter. `cargo run --release -p benilla-lua --example bench`.
use std::time::Instant;
const WORKLOADS: &[(&str, &str)] = &[
("calls (fib 27)", "local function fib(n) if n < 2 then return n end return fib(n-1) + fib(n-2) end return fib(27)"),
("numeric loop", "local s = 0 for i = 1, 5000000 do s = s + i * 2 - 1 end return s"),
("table array", "local t = {} for i = 1, 1000000 do t[i] = i end local s = 0 for i = 1, 1000000 do s = s + t[i] end return s"),
("table hash (string keys)", "local t = {} for i = 1, 200000 do t['k' .. i] = i end local s = 0 for k, v in pairs(t) do s = s + v end return s"),
("table hash (number keys)", "local t = {} for i = 1, 200000 do t[i * 7919] = i end local s = 0 for k, v in pairs(t) do s = s + t[k] end for i = 1, 200000 do s = s + t[i * 7919] end return s"),
("pow (global __pow)", "local s = 0 for i = 1, 1000000 do s = s + i ^ 0.5 end return s"),
("method calls (OOP)", "local C = {} C.__index = C function C:add(x) self.v = self.v + x return self end local o = setmetatable({v = 0}, C) for i = 1, 1000000 do o:add(1) end return o.v"),
("closures", "local s = 0 for i = 1, 300000 do local f = function(x) return x + i end s = s + f(1) end return s"),
("string ops", "local n = 0 for i = 1, 100000 do local s = 'item' .. i .. ':' .. (i * 2) local a, b, k, v = string.find(s, '(%a+)(%d+)') n = n + string.len(s) + string.len(string.upper(k)) end return n"),
("gsub/format", "local n = 0 for i = 1, 50000 do local s = string.format('%d-%s-%5.2f', i, 'x', i / 3) s = string.gsub(s, '%-', '+') n = n + string.len(s) end return n"),
("tinsert/sort", "local t = {} for i = 1, 100000 do table.insert(t, math.mod(i * 7919, 100003)) end table.sort(t) return t[1]"),
];
fn time<F: FnMut()>(mut f: F) -> f64 {
// Best of three.
(0..3)
.map(|_| {
let t = Instant::now();
f();
t.elapsed().as_secs_f64() * 1000.0
})
.fold(f64::MAX, f64::min)
}
fn main() {
// `bench <name>`: that workload alone, five times, for a profiler.
if let Some(only) = std::env::args().nth(1) {
// `noop` measures the fixed cost: a fresh state and a trivial chunk.
// `-e <chunk>`: any chunk, five times.
let custom = std::env::args().nth(2).filter(|_| only == "-e");
let src = if let Some(c) = custom.as_deref() {
c
} else if only == "noop" {
"return 0"
} else {
WORKLOADS
.iter()
.find(|(n, _)| n.contains(&only))
.expect("a workload name")
.1
};
for _ in 0..5 {
let mut vm = benilla_lua::new_state();
vm.exec(src.as_bytes(), b"=bench").expect("runs");
}
return;
}
println!("{:<28} {:>10}", "workload", "ms");
for (name, src) in WORKLOADS {
// One state, the chunk compiled once outside the clock, the best of three runs in that
// warm state.
let mut vm = benilla_lua::new_state();
let f = vm.load(src.as_bytes(), b"=bench").expect("compiles");
let fr = vm.root(f);
let ms = time(|| {
let f = vm.rooted(fr);
vm.pcall_value(f, &[], -1).expect("runs");
});
println!("{name:<28} {ms:>10.1}");
}
}