This directory holds a small harness for quick Ruby protocol benchmarks. Use it to spot read and write regressions in tree.
Run the script with plain ruby from the repo root.
ruby test/rb/benchmarks/protocol_benchmark.rb
This runs the full benchmark set:
thrift_native.so loadsUse flags or env vars to tune a run.
ruby test/rb/benchmarks/protocol_benchmark.rb --large-runs 1 --small-runs 10000
--jsonTHRIFT_BENCHMARK_LARGE_RUNSTHRIFT_BENCHMARK_SMALL_RUNSTHRIFT_BENCHMARK_SKIP_NATIVE=1THRIFT_BENCHMARK_SCENARIOSruby test/rb/benchmarks/protocol_benchmark.rb --json > benchmark.json
[!NOTE]
--jsonkeeps the warm-up pass, but only prints measured results.
[!TIP] Set
THRIFT_BENCHMARK_SKIP_NATIVE=1to force a pure-Ruby run.
Use --scenarios or THRIFT_BENCHMARK_SCENARIOS to run only part of the matrix.
ruby test/rb/benchmarks/protocol_benchmark.rb --scenarios rb-bin-write-large,rb-json-read-large,hdr-zlib-read-small
Each ID has four parts:
rb, c, or hdrbin, cmp, json, or zlibwrite or readlarge or small| ID | Family | Protocol | Operation | Size |
|---|---|---|---|---|
rb-bin-write-large | Ruby | binary | write | large |
rb-bin-read-large | Ruby | binary | read | large |
c-bin-write-large | C native | binary | write | large |
c-bin-read-large | C native | binary | read | large |
rb-cmp-write-large | Ruby | compact | write | large |
rb-cmp-read-large | Ruby | compact | read | large |
rb-json-write-large | Ruby | JSON | write | large |
rb-json-read-large | Ruby | JSON | read | large |
rb-bin-write-small | Ruby | binary | write | small |
rb-bin-read-small | Ruby | binary | read | small |
c-bin-write-small | C native | binary | write | small |
c-bin-read-small | C native | binary | read | small |
rb-cmp-write-small | Ruby | compact | write | small |
rb-cmp-read-small | Ruby | compact | read | small |
rb-json-write-small | Ruby | JSON | write | small |
rb-json-read-small | Ruby | JSON | read | small |
hdr-bin-write-small | Header | binary | write | small |
hdr-bin-read-small | Header | binary | read | small |
hdr-cmp-write-small | Header | compact | write | small |
hdr-cmp-read-small | Header | compact | read | small |
hdr-zlib-write-small | Header | zlib | write | small |
hdr-zlib-read-small | Header | zlib | read | small |
[!NOTE] Native-only IDs fail if
thrift_native.sois not available.
Nested4 payload by default.OneOfEach payloads.protocol_benchmark.rb: benchmark harness and scenario definitions../fixtures/structs.rb: sample structs used by the benchmarkThis harness is for quick in-tree checks. Use --json if you want structured output for scripts, result diffs, or branch comparisons. Run it more than once if you want a wider sample.