Skip to content

Add steady-state decode benchmark#143

Draft
nishantmehta wants to merge 2 commits into
pion:mainfrom
nishantmehta:pr/decode-steady-bench
Draft

Add steady-state decode benchmark#143
nishantmehta wants to merge 2 commits into
pion:mainfrom
nishantmehta:pr/decode-steady-bench

Conversation

@nishantmehta

Copy link
Copy Markdown

What

Adds BenchmarkDecodeSteady, a benchmark for the steady-state, per-frame decode cost.

Why

The existing BenchmarkDecode is skipped unless -oggfile is supplied (loadTestOgg
calls t.Skip when the flag is empty), and when it does run it constructs a new decoder
and re-parses the ogg stream on every iteration. As a result there is no default-running
benchmark that tracks the recurring per-frame decode cost.

BenchmarkDecodeSteady runs on the embedded testdata/tiny.ogg: it parses the packets
once, reuses a single decoder and output buffer, warms up the decoder's scratch buffers,
and then loops the same packets. This isolates per-frame work from one-time setup.

Result

BenchmarkDecodeSteady-6   ~9.3 µs/op   0 B/op   0 allocs/op

It documents and guards the allocation-free steady-state decode path. No production code
changes; go test ./... passes.

nishantmehta and others added 2 commits June 24, 2026 11:16
BenchmarkDecode is skipped unless -oggfile is given and rebuilds the decoder
and re-parses the stream every iteration, so it cannot track per-frame decode
cost by default. Add BenchmarkDecodeSteady, which runs on the embedded
tiny.ogg: it parses the packets once, reuses a single decoder and output
buffer, warms up scratch, then loops the same packets. This isolates the
recurring per-frame work (currently 0 allocs/op) from one-time setup.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant