Recording Inputs for a Microbenchmark

A microbenchmark measures a narrow operation under controlled inputs. Describe data shape and setup so another run tests the same work.

Source
Anbloq
Language
English
Created
Updated
Chapters
4
Reading time
1 min
In this article4 chapters
  1. Trace string length
  2. Move setup deliberately
  3. Capture the data properties that govern runtime
  4. Define the cost included for construction

Trace string length

Comparing two short labels can hide the cost of a long shared prefix before a mismatch. Generate or store both input patterns. See numeric and lexicographic comparison.

Move setup deliberately

Creating all strings inside the timed period measures allocation as well as comparison. Choose which costs the measurement includes. Defining the timed operation sets that boundary.[1]

Capture the data properties that govern runtime

A string-search test with independent short words can behave differently from equal-length words sharing a long prefix. Record count, total bytes and repetitions or generation seed. The same nominal input size can produce different comparison work. See operation counts and measurement.

Record dataset identity and generator
Note token lengths and duplicate rates
Store representative failing or surprising input when feasible

Define the cost included for construction

Building a corpus can happen outside a query timing or be part of a cold workload. Document that choice. Verify a result so an apparently fast run still did the intended work.

References

  1. Google, Site Reliability Engineering ↩