json-performance Reference
Script defined in `lua/console/json-performance.lua`. Comprehensive serialization performance benchmark comparing JSON, lpack, lpack binary, and string.buffer encode/decode speeds.
Script defined in lua/console/json-performance.lua. Comprehensive serialization performance benchmark comparing JSON, lpack, lpack binary, and string.buffer encode/decode speeds.
Functions/Exports
No module exports (standalone script). Contains the following local helper functions that run sequentially:
test() (local)
Main orchestrator - discovers .jbeam files, reads them, runs JSON decode benchmark, then calls each serialization test function.
testLpackEncode() (local)
Benchmarks lpack.encode() on all parsed tables, reports packed size and MB/s throughput.
testLpackDecode() (local)
Benchmarks lpack.decode() on lpack-encoded data, reports MB/s throughput.
testLpackEncodeBin() (local)
Benchmarks lpack.encodeBin() (binary variant), reports packed size and MB/s.
strbufEncode() (local)
Benchmarks LuaJIT string.buffer encode on all parsed tables, reports packed size and MB/s.
strbufDecode() (local)
Benchmarks string.buffer decode, reports MB/s throughput.
Tests Performed
- File discovery - finds all
*.jbeamfiles in/vehicles - File reading - reads all files into memory, reports size and throughput (MB/s)
- JSON decode - parses all jbeam files 6x, measures throughput
- lpack encode - encodes parsed Lua tables to lpack format, reports compressed size and throughput
- lpack decode - decodes lpack data back, measures throughput
- lpack encodeBin - binary variant of lpack encoding
- lpack decodeBin - decodes binary lpack
- string.buffer encode - LuaJIT string.buffer serialization
- string.buffer decode - string.buffer deserialization
Configuration
reruns = 6- number of iterations for each test
Usage
beamng -console lua/console/json-performance.luaInternal Notes
- Uses
HighPerfTimerfor precise measurements - Reports MB/s throughput for each serialization method
- Calls
collectgarbage()before each test for clean measurements - Compares 4 serialization formats: JSON, lpack, lpack binary, string.buffer
- Reports total packed sizes to compare compression ratios
- JIT toggle is commented out but available for testing JIT impact
BeamConsole Folder Overview
Console scripts for BeamNG.drive - benchmarks, tests, and utilities run outside the game engine in headless/console mode.
main Reference
Script defined in `lua/console/main.lua`. Bootstrap/initialization script that sets up the Lua environment for console mode, configuring package paths and loading core dependencies.