skillfed

google-benchmark

A library to benchmark code snippets.

google-benchmark v1.9.5 75.3K downloads/30d#14,726 on PyPI10,351
Permissive license Apache-2.0 Active released

What it is and what it does

google-benchmark is a Python wrapper around Google's C++ benchmarking library, designed to measure and compare the performance of code snippets with statistical rigor. Unlike simple timing, it runs code multiple times under controlled conditions to produce reliable performance metrics. The library is modeled after unit-testing frameworks, so if you've used pytest or similar tools, the structure will feel familiar.

You define benchmark functions, register them with decorators or macros, and run them to get detailed timing statistics. It has no runtime dependencies beyond Python itself, making it lightweight to deploy. The package supports Python 3.10 through 3.13 and is actively maintained; precompiled wheels are available for common platforms (macOS, Linux, Windows across x86_64 and ARM architectures).

Use it for:

  • Measure and compare performance of different algorithm implementations to choose the fastest one
  • Track performance regressions in CI/CD pipelines by benchmarking code before and after changes
  • Profile hot paths in Python applications to identify optimization targets
  • Generate reproducible performance reports for code review and documentation
  • Validate that optimizations actually improve performance with statistical confidence

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Provides Python bindings to Google's C++ benchmarking library, allowing you to measure and compare the performance of code snippets with statistical rigor.

Yes, if you need rigorous performance measurement. The library is actively maintained, has no runtime dependencies, and Apache-2.0 licensing poses no restrictions. Medium install friction is acceptable for a compiled package with broad platform support. Best suited for developers who want statistical benchmarking beyond simple timing—if you only need quick profiling, lighter tools may suffice.

Install

google-benchmark on PyPI

pip

pip install google-benchmark

uv

uv add google-benchmark

poetry

poetry add google-benchmark

Installing google-benchmark

Before you install

Medium install friction due to compiled wheels for multiple platforms and Python versions (3.10–3.13). Active maintenance with recent releases; no runtime dependencies simplifies deployment once installed.

License in practice

Apache-2.0 permissive license allows use in proprietary and open-source projects with minimal restrictions; attribution required.

Quickstart

pip install google-benchmark

import benchmark

@benchmark.register
def BM_example(state):
    for _ in state:
        # Code to measure
        pass

Requires Python 3.10 or later; precompiled wheels available for macOS (x86_64, arm64), Linux (x86_64, aarch64), and Windows (amd64).

Verify before relying

  • Exact API surface and decorator/function signatures for Python bindings beyond the C++ example shown
  • Whether the package includes statistical analysis features (e.g., confidence intervals, regression detection) mentioned in the C++ docs
  • Performance overhead of the Python binding layer compared to native C++ benchmarking

Package facts

License Apache-2.0 (permissive)
Python support supports the current Python release (>=3.10)
Install friction medium — platform-specific wheel
Runtime dependencies none
Maintenance actively maintained — 193 days since the last release
Last repo commit
First released
Downloads 75,335/month — #14,726 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: google_benchmark-1.9.5-cp310-cp310-macosx_10_14_x86_64.whl; google_benchmark-1.9.5-cp310-cp310-macosx_11_0_arm64.whl; google_benchmark-1.9.5-cp310-cp310-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl; google_benchmark-1.9.5-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl; google_benchmark-1.9.5-cp310-cp310-win_amd64.whl; google_benchmark-1.9.5-cp311-cp311-macosx_10_14_x86_64.whl; google_benchmark-1.9.5-cp311-cp311-macosx_11_0_arm64.whl; google_benchmark-1.9.5-cp311-cp311-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl; google_benchmark-1.9.5-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl; google_benchmark-1.9.5-cp311-cp311-win_amd64.whl; google_benchmark-1.9.5-cp312-abi3-macosx_10_14_x86_64.whl; google_benchmark-1.9.5-cp312-abi3-macosx_11_0_arm64.whl; google_benchmark-1.9.5-cp312-abi3-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl; google_benchmark-1.9.5-cp312-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl; google_benchmark-1.9.5-cp312-abi3-win_amd64.whl

Keywords: benchmark

Development Status :: 4 - BetaIntended Audience :: DevelopersIntended Audience :: Science/ResearchProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Topic :: Software Development :: TestingTopic :: System :: Benchmark

Tags

python benchmarking libraryperformance measurement toolcode timing and profilingstatistical benchmarksgoogle benchmark pythonmicrobenchmark frameworkperformance testing
performance-testingbenchmarkingprofiling

More Testing packages