Closed fengalin closed 5 years ago
Before any changes:
test bench_append_samples ... bench: 4,660 ns/iter (+/- 30)
test bench_render_buffers ... bench: 20,699,294 ns/iter (+/- 656,395)
Storage as i16
:
test bench_append_samples ... bench: 4,669 ns/iter (+/- 20)
test bench_render_buffers ... bench: 18,788,012 ns/iter (+/- 1,398,147)
Storing samples a SmallVec
s of channels:
test bench_append_samples ... bench: 4,346 ns/iter (+/- 42)
test bench_render_buffers ... bench: 18,975,297 ns/iter (+/- 1,482,715)
Drawing each channel completely:
test bench_append_samples ... bench: 4,674 ns/iter (+/- 84)
test bench_render_buffers ... bench: 12,478,807 ns/iter (+/- 423,996)
Here are the identified approaches:
i16
to store the sample values (actually the channel values). The aim is to use a more compact buffer in order to improve cache locality. It also pushes the actual conversion to another format (namelyf64
forWaveformImage
) to the caller.SmallVec
in theAudioBuffer
. The idea is to get all channels from a sample Index at once from the the ring buffer.Thanks to the recent addition of benches, we can now verify the gains from these approaches.