Skip to content

[FEATURE] tools/compare_renders.py: compare two render builds, model by model - #346

Open
squatchlr wants to merge 1 commit into
sdatkinson:mainfrom
Squatch-Stack:submit/compare-renders
Open

squatchlr wants to merge 1 commit into
sdatkinson:mainfrom
Squatch-Stack:submit/compare-renders

Conversation

@squatchlr

Copy link
Copy Markdown

Adds tools/compare_renders.py, for reviewing a speed-up: does the faster build still produce the same audio, model by model?

python3 tools/compare_renders.py build-base/tools/render build-candidate/tools/render

It renders every model (default example_models/*.nam; .wav impulse responses work too) with both binaries and prints, per model:

  • EXACT: byte-identical;
  • NEAR: error-to-signal ratio below -100 dB and no sample off by more than 1e-4;
  • DIFFERENT: anything else, with the first differing sample and the error.

It exits 0 if no model differs, 1 if one does, and 2 if a render fails.

---
title: Reviewing a speed-up
---
flowchart TD
  accTitle: Reviewing a speed-up
  accDescr: Build the base and the candidate, run compare_renders.py on both render binaries, then read the speed numbers only if every model is exact or near.

  n_build["build base and candidate"] --> n_cmp["compare_renders.py base cand"] --> n_q{"every model<br/>EXACT or NEAR?"}
  n_q -- yes --> n_speed["look at the speed numbers"]
  n_q -- no --> n_ask["which model, which sample?"]
Loading

The test signal is generated at each model's own sample rate, with an odd length so the last block is always short. It is a sweep, noise, silence and a full-scale square. Standard library only, so there is nothing to install. --self-test checks the comparison itself: EXACT, NEAR and DIFFERENT thresholds, one wrong sample, a NaN, and truncated renders.

render writes output channel 0 only, so only that channel is compared. Comparing an -O3 build with an -Ofast build of main: two models are EXACT, the rest are NEAR (worst -119 dB, largest sample difference 1.8e-5).

For reviewing a speed-up: renders every model with a base and a candidate
tools/render binary and prints EXACT, NEAR or DIFFERENT per model, with the
first differing sample. NEAR means an error-to-signal ratio below -100 dB
and no sample off by more than 1e-4, so one wrong sample in a long render
is DIFFERENT; so is a NaN.

- The test signal is generated at each model's own sample rate (48 kHz when
  a model declares none; a .wav impulse response at its file's rate), and its
  length is odd, so the last block of any power-of-two size is short.
- Renders shorter than the input are DIFFERENT even when they agree.
- Exits 0 if no model differs, 1 if one does, 2 if a render fails.
- render writes output channel 0 only, so only that channel is compared.

Standard library only; --self-test checks the comparison itself.
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