Skip to main content

Method

How a number on these pages is computed, and how to get the same numbers on your own machine.

Each corpus entry ii is one image (a genre, a size and a format). For a library LL, tiLt_i^{L} is the best of 7 timed runs of one operation on entry ii, siLs_i^{L} is the size in bytes of the file it wrote, and miLm_i^{L} is its extra peak memory. Two libraries are compared only on the entries where both ran.

  • Reference library. WL=∣{ i:tiL=min⁡KtiK }∣W_L=\bigl|\{\,i : t_i^{L}=\min_K t_i^{K}\,\}\bigr| is the number of entries on which LL was fastest, and ref=arg⁡max⁡LWL\mathrm{ref}=\arg\max_L W_L is the library that won the most. The count shows up in the per-operation summaries.
  • Headline ratio. Over the NN entries both libraries ran, E ⁣[tLtref]=1N∑i=1NtiLtiref\mathbb{E}\!\left[\dfrac{t_L}{t_{\mathrm{ref}}}\right]=\dfrac{1}{N}\sum_{i=1}^{N}\dfrac{t_i^{L}}{t_i^{\mathrm{ref}}}. It is the mean of each entry's own ratio (ratio first, then average), so a 64x64 image counts as much as a 4000x4000 one. Above 1 means LL took longer than the reference. Output size and extra memory use the same formula with ss and mm in place of tt.
  • Trend charts. For an image of zz pixels, let GzG_z be the synthetic entries of that size (photo, gradient, noise, graphics). Each library's point is tˉL(z)=(∏i∈GztiL)1/∣Gz∣\bar t_L(z)=\Bigl(\prod_{i\in G_z} t_i^{L}\Bigr)^{1/|G_z|} for time, throughput z/106tˉL(z)\dfrac{z/10^{6}}{\bar t_L(z)} in MP/s, and mˉL(z)=1∣Gz∣∑i∈GzmiL\bar m_L(z)=\dfrac{1}{|G_z|}\sum_{i\in G_z} m_i^{L} for memory. Real photographs each have an odd size of their own, so they are left out of these charts (they still count in every ratio above).
  • Reading a ratio. Averaging ratios is not symmetric: a library 10 times faster on one entry and 10 times slower on another scores E=(0.1+10)/2=5.05\mathbb{E}=(0.1+10)/2=5.05, not 1. Read it together with the win count WLW_L.

Reproduce​

From the repository root:

cmake -S benchmarks -B benchmarks/build
cmake --build benchmarks/build --target stb_benchmark

stb_benchmark builds the corpus, checks every output (nothing is timed before every library's result has passed), measures speed and memory, and writes benchmarks/outputs/. Each step is also its own target (cmake --build benchmarks/build --target <name>); benchmarks/README.md lists them, and explains how the corpus was built, why timing is best-of-N, and the memory-measurement problem the suite works around.

The site draws what is committed in benchmarks/outputs/, so after a new run commit that folder and build the site again (python3 scripts/prepare.py bench copies it).