w3grs
w3grs is a Rust port of w3gjs, intended to be a clean library for parsing Warcraft III replay files in other Rust projects.
The upstream TypeScript source is tracked as a Git submodule in upstream/w3gjs for parity tests, benchmarks, and future maintenance. The published crate contains the Rust library and a small fixture subset, not the full upstream replay corpus.
Installation
w3grs requires Rust 1.85 or newer.
Development Checkout
Clone with submodules when you want to run the repository's w3gjs parity and speed comparison scripts:
For an existing checkout:
Usage
use W3GReplay;
Lower-level parser layers are also public:
RawParserfor replay headers and compressed data blocksMetadataParserfor lobby/map/player setup dataGameDataParserandActionParserfor timeslots, chat, leave events, and player actionsReplayParserfor the combined low-level parse output
Consumers that need both the high-level summary and the raw action stream can parse once and use the timed action helper:
use ;
Benchmark
From a development checkout with the submodule initialized, compare local w3gjs and w3grs parsing speed on the same replay:
Useful options:
The benchmark reads the replay once per parser process, warms both parsers, then reports timed in-process parses. --prepare runs the local w3gjs install/build and builds the Rust benchmark binary in release mode.
Example smoke result on this repo's reforged1.w3g fixture with 2 timed iterations and 1 warmup:
Replay: upstream/w3gjs/test/replays/132/reforged1.w3g
Iterations: 2 timed, 1 warmup
Parser total ms mean ms min ms max ms players
w3gjs 61.179 30.589 30.201 30.977 2
w3grs 1.863 0.932 0.849 1.014 2
w3grs mean speedup vs w3gjs: 32.84x
Benchmark results vary by machine, replay, iteration count, and current CPU load. Use larger iteration counts for less noisy comparisons:
Upstream Parity And Speed Sweep
From a development checkout, check every replay fixture in upstream/w3gjs/test/replays for output parity while timing both parsers:
The sweep reports:
- exact canonical JSON byte parity, including
parseTime - normalized canonical JSON parity with
parseTimeremoved w3gjsandw3grsmean parse time per replay- aggregate mean/min/max speedup
parseTime is expected to break exact parity because it measures each parser's runtime. Normalized parity is the useful output-equivalence signal.
Useful options:
Recent local smoke result on the upstream submodule replay fixtures with 1 timed parse and no warmup:
Replays: 50
Exact byte parity: 0/50 (mismatches include expected parseTime differences)
Normalized parity without parseTime: 50/50
Speedup mean/min/max: 17.99x / 2.81x / 78.62x