ByteBlitz is a CLI tool I built to scratch an itch: I wanted a simple way to benchmark small code snippets without setting up a full testing framework.

What it does

You give it a snippet, it runs it N times, and gives you statistics: mean, median, p95, p99, standard deviation. It handles warmup runs automatically and can compare multiple implementations side by side.

$ byteblitz run --lang python "sorted([3,1,4,1,5,9,2,6])" --iterations 10000

  mean:   1.23µs
  median: 1.18µs
  p95:    1.89µs
  p99:    2.34µs
  stddev: 0.42µs
  runs:   10,000

Why I built it

Existing benchmarking tools are either too heavy (full framework setup) or too light (just time in a shell). I wanted something in between — quick to use but statistically rigorous.

Technical details

  • Written in Go for fast startup time
  • Uses sub-process isolation to prevent benchmark pollution
  • Statistical outlier detection using modified Z-scores
  • Supports Python, JavaScript, Go, and Rust snippets
  • Output formats: table, JSON, CSV

The hardest part was getting accurate timing for sub-microsecond operations. Go’s time.Now() has ~100ns resolution on most systems, so for very fast snippets you need to batch iterations and divide.