On this page
Overview
Google Benchmark is a C++ library for defining microbenchmarks in a unit-test-like style. It manages iterations and timing and supports fixtures, arguments, threads, manual timing, custom counters and statistics, plus console and JSON reporting.
Features and best fit
Based on official documentation; not hands-on tested · Content checked:
Key features
Register benchmark functions and let the library manage iterations
Benchmarks use benchmark::State and the BENCHMARK macro while the library adjusts iteration counts, measures execution, and reports results.
Model workloads with arguments, fixtures, threads, manual timing, and counters
Parameterized benchmarks, fixtures, multithreading, manual timing, custom counters, complexity calculations, and statistics support richer performance experiments.
Sources: [2]
Control runs with filters, dry-run mode, and structured output
Runs can be filtered by regex and emitted as console or JSON output. --benchmark_dry_run executes one iteration and one repetition to validate benchmark wiring quickly.
Sources: [2]
Best fit
Before adoption
Consumer code may use C++11 but building the library requires C++17
The v1.9.5 README states that applications can use the library with C++11, while building Google Benchmark itself requires C++17 compiler and standard-library support.
Control build mode and machine variance before interpreting results
The default build is Debug and is not appropriate for representative performance measurements. CPU scaling, background work, optimization, and environment noise affect microbenchmarks, so comparisons should hold conditions constant. The experimental v2 branch has no stability guarantee.
Official sources
- [1]Google Benchmark v1.9.5 README(2026-10-04)
- [2]Google Benchmark v1.9.5 user guide(2026-10-04)
- [3]Google Benchmark v1.9.5 release(2026-10-04)
- [4]Google Benchmark v1.9.5 CMake configuration(2026-10-04)
- [5]Google Benchmark Apache 2.0 license(2026-10-04)
Supplemental curator note
Use Release builds for meaningful performance comparisons and control CPU scaling and background load. Consumer code may use C++11, but building the library itself requires C++17.
Try it in 3 steps
- 1
Fetch Google Benchmark v1.9.5
Pin the checkout to the stable release tag.
git clone --depth 1 --branch v1.9.5 https://github.com/google/benchmark.git benchmark-1.9.5 - 2
Build the Release library without tests
Use a Release build for performance work and skip the GoogleTest-dependent test suite.
cmake -S benchmark-1.9.5 -B benchmark-1.9.5/build -DCMAKE_BUILD_TYPE=Release -DBENCHMARK_ENABLE_TESTING=OFF && cmake --build benchmark-1.9.5/build -j2 - 3
Compile a minimal benchmark and use dry-run mode
Run only one iteration and one repetition to validate the benchmark wiring without a long performance run.
printf '#include <benchmark/benchmark.h>\nstatic void BM_Add(benchmark::State& s){for(auto _ : s){int x=1+1; benchmark::DoNotOptimize(x);}}\nBENCHMARK(BM_Add);\nBENCHMARK_MAIN();\n' > benchmark-demo.cc && c++ -std=c++11 -Ibenchmark-1.9.5/include benchmark-demo.cc -Lbenchmark-1.9.5/build/src -lbenchmark -lpthread -o benchmark-demo && ./benchmark-demo --benchmark_dry_run
Growth
Growth trends · Last 30 days
10,449 Stars
Trend data is still being collected.
Development activity
Last 90 days · weekly
- Commits (last 30 days)
- 12
- Open PRs
- 23
Development activity is still being collected.
Built with
Categories and tags
Categories
GitHub data
GitHub dataView detailed GitHub data
GitHub Topics
- benchmark
- Stars
- 10,449
- Forks
- 1,810
- Watchers
- 204
- Open issues
- 151
- Contributors
- 358
- Owner type
- Organization
- Primary language
- C++
- License
- Apache-2.0
- Repository last updated
- Oct 2, 2026
Related information
Write a related articleShare a guide or use case for this OSS in Markdown. Articles are published after administrator approval.
Explore next
- CodeceptJS4,242 Stars
1 shared tag(s) · 2 shared category(s)
unify Playwright and other E2E engines behind user-perspective
JavaScriptIsteps - WebMock4,049 Stars
1 shared tag(s) · 2 shared category(s)
stub Ruby HTTP requests without real network calls and verify expectations against methods, URIs, headers, and bodies
Ruby - Fluent Assertions3,813 Stars
1 shared tag(s) · 2 shared category(s)
express expected outcomes and failure reasons in .NET unit tests through readable
C#.Should()-style assertions - Catch221,505 Stars
2 shared tag(s) · 2 shared category(s) · Same language
write C++ unit tests, BDD scenarios, and micro-benchmarks in one test framework and integrate them with CMake and CTest
C++ - GoogleTest39,616 Stars
2 shared tag(s) · 1 shared category(s) · Same language
write C++ unit tests, assertions, parameterized tests, death tests, and mocks with Google's testing framework
C++ - Playwright97,062 Stars
1 shared tag(s) · 2 shared category(s)
Drive Chromium, Firefox, and WebKit through one API and test runner for E2E, scripting, and agent browser automation
TypeScript
Report incorrect information
Tell us if any listing information is incorrect or outdated.