liveBook · Manning

Benchmark

As explained in Learn Go with Pocket-Sized Projects

Benchmarking is the measurement and comparison of program performance across implementations or versions.

Benchmarking measures and compares program performance across algorithms, implementations, or versions. In Go, the built-in bench command supports repeatable performance checks alongside ordinary tests. section 1.3.1 section 1.4

Use benchmarks to:

  • Compare different algorithms or implementations. section 1.3.1
  • Compare versions and check each commit for performance deterioration. section 1.3.1
  • Measure concurrency choices, such as buffered-channel sizes, on hardware resembling the deployment machine. section 7.5.2

Benchmark the workload, not just the code

A remote-file workload can overload or trigger limits on the server, while single-machine video encoding can already saturate the CPU. Benchmark concurrency choices under a similar machine architecture before increasing parallelism; otherwise, extra goroutines may make performance worse. section 7.5.2

How Learn Go with Pocket-Sized Projects covers it

How deep it goes
Explains comparison and regression purposes, then qualifies measurements by workload type and machine architecture.
Examples
Uses algorithm comparisons, commit checks, buffered-channel sizing, remote files, and CPU-intensive video encoding.
What you can do after
Evaluate performance with Go's built-in bench command and diagnose whether concurrency changes improve or degrade a workload.
How it connects
Connects benchmarking with unit testing, profiling, concurrency, goroutines, channels, and performance regression detection.

Also explained in

Compare how 23 books explain benchmark →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn Go with Pocket-Sized Projects. The section links point to the parts of the book it draws on.