OSS TanbouSign in with GitHub

write C++ microbenchmarks with a unit-test-like API and measure timing, iterations, counters, and statistics

About these scores

OSS scale score is an unbounded metric that log-compresses and weights Stars, Watchers, Forks, and Contributors. Discovery score is the current OSS scale score minus the score at discovery. Update pace is commits in the last 30 days, growth momentum is the OSS scale score difference within the recent observation window, and OSS health is a 0–100 rating based on available recency, Community Health, and release data.

Stars
10,449
Primary language
C++
License
Apache-2.0
Repository last updated
Oct 2, 2026
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.

Sources: [1][2]

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

Fits reproducible comparisons of C++ functions, algorithms, and container implementations

It is useful for performance-regression tests and implementation comparisons that should live in source control and run consistently in local or CI environments.

Sources: [1][2]

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.

Sources: [1][4]

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.

Sources: [1][2]

Official sources

  1. [1]Google Benchmark v1.9.5 README(2026-10-04)
  2. [2]Google Benchmark v1.9.5 user guide(2026-10-04)
  3. [3]Google Benchmark v1.9.5 release(2026-10-04)
  4. [4]Google Benchmark v1.9.5 CMake configuration(2026-10-04)
  5. [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. 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. 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. 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
Check the official README

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

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
Write a related article

Share a guide or use case for this OSS in Markdown. Articles are published after administrator approval.

Report incorrect information

Tell us if any listing information is incorrect or outdated.

After reading this page, do you know what to do next?