--- id: google-benchmark version: "1.9.5" license: Apache-2.0 license_treatment: permissive maintenance: active --- # google-benchmark — A library to benchmark code snippets. License: permissive · Maintenance: active · Downloads: 75.3K/mo ## 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 above — 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 pip install google-benchmark uv add google-benchmark 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_current - Install friction: medium - Maintenance: active - Downloads: 75.3K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags python benchmarking library, performance measurement tool, code timing and profiling, statistical benchmarks, google benchmark python, microbenchmark framework, performance testing, performance-testing, benchmarking, profiling [View on SkillFed](https://skillfed.io/packages/google-benchmark) · [View on PyPI](https://pypi.org/project/google-benchmark/)