95 Commits

Author SHA1 Message Date
Tuna Kılıç b3a8d2f88e docs: document Bazel integration (#2238)
* docs: document Bazel integration

* fix(docs): avoid pinning current benchmark version
2026-07-02 09:50:00 +01:00
dominic eb15fc80dd Introduce Rust bindings (#2221)
* add Rust bindings

* clang-format

* pre-commit fix

* windows static builds

* Rust prefers MD on windows

* check in lock file to avoid source poisoning

* use a rust crate name that isn't taken

* add CMake target for running Rust binding tests and integrate into CI

* complete crate rename

* enable test dependency downloads in Rust bindings CI
2026-06-15 14:29:03 +01:00
Haihan Jiang 6408acf50a Clarify DoNotOptimize const-ref warning (#2201)
Improve docs for `DoNotOptimize()`, and make it's compile-time diagnostic suggest a possible fix
2026-05-27 06:46:27 +03:00
Mister Lobster dea73efb31 docs: Add comprehensive command-line options documentation (#2187)
This commit adds detailed documentation for all benchmark command-line
options to the user guide. Each option is documented with:

- Description of what the option does
- Default value (where applicable)
- Valid values (where applicable)
- Example usage

The documentation is organized into logical categories:
- Benchmark Selection and Execution
- Timing and Repetition Control
- Output Formatting
- Reporting Options
- Performance Counters and Context
- Miscellaneous

This addresses issue #2156 where users requested public documentation
of command-line options instead of having to run --help.

Closes #2156
2026-05-07 11:12:09 +01:00
Shreejay Kurhade f43ed80fa2 Docs: JSON output format (#2181)
* Document JSON output format

* Soften JSON output documentation

* Clarify JSON counter output example

---------

Co-authored-by: dominic <510002+dmah42@users.noreply.github.com>
2026-04-27 11:29:29 +01:00
Shreejay Kurhade ec0ce391ce Document naming benchmark arguments (#2180) 2026-04-26 18:07:35 +01:00
Christoph Grüninger 8abf1e701f [doc] Properly document CMake minimum required version as 3.13 (#2162) 2026-04-05 23:54:59 +03:00
dominic fc8a082c60 feat: Add ScopedPauseTiming RAII helper (#2157)
* feat: Add ScopedPauseTiming RAII helper

Adds a new `benchmark::ScopedPauseTiming` class that provides a convenient
RAII-style mechanism for pausing and resuming benchmark timers.

This is less error-prone than manually calling `PauseTiming` and
`ResumeTiming`, as it guarantees that the timer is resumed when the
scope is exited.

- Added `ScopedPauseTiming` to `include/benchmark/state.h`.
- Added a new test `test/scoped_pause_test.cc` to verify the
  functionality and prevent regressions.
- Updated `test/CMakeLists.txt` to include the new test.
- Added documentation for the new feature in `docs/user_guide.md`.

* Bump astral-sh/setup-uv from 7.6.0 to 8.0.0 (#2160)

Bumps [astral-sh/setup-uv](https://github.com/astral-sh/setup-uv) from 7.6.0 to 8.0.0.
- [Release notes](https://github.com/astral-sh/setup-uv/releases)
- [Commits](https://github.com/astral-sh/setup-uv/compare/37802adc94f370d6bfd71619e3f0bf239e1f3b78...cec208311dfd045dd5311c1add060b2062131d57)

---
updated-dependencies:
- dependency-name: astral-sh/setup-uv
  dependency-version: 8.0.0
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump lukka/get-cmake from 4.3.0 to 4.3.1 (#2159)

Bumps [lukka/get-cmake](https://github.com/lukka/get-cmake) from 4.3.0 to 4.3.1.
- [Release notes](https://github.com/lukka/get-cmake/releases)
- [Changelog](https://github.com/lukka/get-cmake/blob/main/RELEASE_PROCESS.md)
- [Commits](https://github.com/lukka/get-cmake/compare/b78306120111dc2522750771cfd09ee7ca723687...ea83089aa35e08e459464341fe24ad024ee2466f)

---
updated-dependencies:
- dependency-name: lukka/get-cmake
  dependency-version: 4.3.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: dominic <510002+dmah42@users.noreply.github.com>

* Bump numpy from 2.4.3 to 2.4.4 in /tools (#2158)

Bumps [numpy](https://github.com/numpy/numpy) from 2.4.3 to 2.4.4.
- [Release notes](https://github.com/numpy/numpy/releases)
- [Changelog](https://github.com/numpy/numpy/blob/main/doc/RELEASE_WALKTHROUGH.rst)
- [Commits](https://github.com/numpy/numpy/compare/v2.4.3...v2.4.4)

---
updated-dependencies:
- dependency-name: numpy
  dependency-version: 2.4.4
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: dominic <510002+dmah42@users.noreply.github.com>

* handle move operators

* Use manual time instead of real time for better repeatability

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-04-02 09:57:26 +01:00
Felmon 8dc85aebe0 docs: document benchmark_min_time CLI forms (#2154)
* docs: document benchmark_min_time CLI forms

* chore: trigger CLA rescan

* docs: clarify benchmark_min_time precedence
2026-03-26 09:51:33 +00:00
Ben King fbb750d797 Add BENCHMARK_NAMED macro for named benchmarks without lambda (#2135)
* Add BENCHMARK_NAMED macro for named benchmarks without lambda

  Closes #2128. BENCHMARK_CAPTURE creates a lambda even when no arguments
  are captured, causing compiler/linker scalability issues with thousands
  of benchmarks. BENCHMARK_NAMED provides the same func/name format but
  passes the function pointer directly (no lambda), consistent with the
  existing BENCHMARK macro.

* Move BENCHMARK_NAMED test to register_benchmark_test with name assertions

* Add Benjamin King to AUTHORS and CONTRIBUTORS

* Fix clang-format: remove trailing spaces from BENCHMARK_NAMED macro

* Fix clang-format: remove extra blank line left after test removal

---------

Co-authored-by: Roman Lebedev <lebedev.ri@gmail.com>
2026-02-27 12:01:58 +00:00
Jesse Rosenstock 90ebbdedf0 Make the Benchmark class public (#2101)
Move ::benchmark::internal::Benchmark to ::benchmark::Benchmark.

It's a bit odd that the documented way to pass arguments to a
benchmark is with `benchmark::internal::Benchmark`.  Make this
public instead.

https://github.com/google/benchmark/blob/v1.9.4/docs/user_guide.md#passing-arguments

https://raw.githubusercontent.com/google/benchmark/refs/tags/v1.9.4/docs/user_guide.md#:~:text=void%20CustomArguments(benchmark%3A%3A-,internal%3A%3ABenchmark,-*%20b)%20%7B%0A%20%20for%20(int

Keep ::benchmark::internal::Benchmark as a deprecated forwarding alias.
Uses of Benchmark in the internal namespace need to explicitly use
::benchmark::Benchmark to avoid the deprecation warning.
2026-01-14 21:04:17 +03:00
Frank Rosner 3e7dac665b #2080: Fix rate and thread rate counter aggregates (#2081)
* Update counter.cc

* User counters: normalize time by thread count

Fixes https://github.com/google/benchmark/issues/2080

* docs

---------

Co-authored-by: Roman Lebedev <lebedev.ri@gmail.com>
2025-12-10 21:38:32 +03:00
Prithvi P Rao ce80955d26 [doc] Added nice to reducing_variance (#1994)
* docs:added nice to reducing_variance

* Added self as contributor
2025-05-23 15:20:32 +01:00
Andrewyuan34 afd9c342fb Update build instructions for Visual Studio (#1980) 2025-05-09 07:19:10 +03:00
Roman Lebedev f02794a8bd Automatic ASLR disablement (#1978)
While ASLR is a useful security hardening feature,
it introduces unreproducible noise into benchmarks,
and we really really really don't want any noise,
especially easily avoidable one.

Unless prevented by some other security hardening,
we can disable ASLR for the current process,
and restart it, thus eliminating this noise.

Fixes https://github.com/google/benchmark/issues/461
2025-05-01 17:34:09 +01:00
Roman Lebedev bc0989adee Detect and report ASLR status (#1977)
* Detect and report ASLR status

Theoretically, we could just disable ASLR in `main()`,
but that seems to be disallowed by default
by some other security features.

Refs. https://github.com/google/benchmark/issues/461

* Add a note about ASLR on other OS.
2025-05-01 17:32:16 +03:00
krzikalla ff52b227db Fixed private macro name issue (#1968) 2025-04-11 15:02:03 +01:00
krzikalla f828d71c59 Method templates for Fixtures introduced (#1967) 2025-04-11 12:25:46 +01:00
krzikalla 0da57b85cf Threading api refactor (#1955)
Refactor the multi-threading api to support
using custom user-provided thread factory
instead of always spawning POSIX Threads.
2025-03-29 10:49:25 +03:00
Roman Lebedev 1bc59dce27 Finish cxx version bump (#1948)
* `CMakeLists.txt`: drop hopefully obsolete code

* README.md: update

* Unbreak `BENCHMARK_HAS_CXX11` macro

835365f99a stopped defining it,
but didn't un-conditionalize the code guarded under it...

* Drop `BENCHMARK_HAS_NO_VARIADIC_REGISTER_BENCHMARK`

We no longer support such an old gcc version

* `docs/user_guide.md`: proofread

* Add a test to ensure that `benchmark.h` remains C++14 header

* Revert `[[maybe_unused]]` changes - it requires C++17

* Also support C++11 standard for using the library

I don't think we want to support C++03 though,
but i suppose C++11 is palatable, at least right now.
2025-03-17 09:18:19 +00:00
Guo Ci d26047a0ac Improve examples on ComputeStatistics (#1881) 2024-11-27 09:41:06 +00:00
Alfredo Daniel Esponda Cervantes 761305ec3b Update user_guide.md (#1863)
PR for Issue #819: Fix Suffix in Console Format Table
This PR fixes an issue with an incorrect suffix displayed in the console output. 

Fixes #819.
2024-10-12 00:16:37 +03:00
Dominic Hamon 3fd1e6a7ae add dry run docs 2024-09-13 10:06:24 +01:00
Nicholas Junge 986423a62d Bump oldest supported Python to 3.10, eliminate setuptools-scm (#1842)
* Supply MacOS deployment target to delocate, use build+uv frontend

This shaves off multiple minutes from the wheel builds alone.

Also revert to trusted publishing for wheel uploads as it is now set up.

* Bump oldest supported Python to 3.10, eliminate setuptools-scm

The version is now a string again, under the same attribute as it was
before. This is a pragmatic decision in order to be able to upload wheels
again, possibly directly from main.

We could in the future also set the Python version to a development version
if we want to avoid accidental uploads of `main`.

* Add a note on supported Python versions in the docs

Also fixes the setuptools failure observed in the latest CI by pinning
to the last version before v73 until the problem is identified and resolved.
2024-09-04 17:42:07 +01:00
xdje42 7c8ed6b082 [FR] Add API to provide custom profilers #1807 (#1809)
This API is akin to the MemoryManager API and lets tools provide
their own profiler which is wrapped in the same way MemoryManager is
wrapped. Namely, the profiler provides Start/Stop methods that are called
at the start/end of running the benchmark in a separate pass.

Co-authored-by: dominic <510002+dmah42@users.noreply.github.com>
2024-07-16 09:56:40 +01:00
Jiawen (Kevin) Chen d2cd246e19 Clarify the difference between BENCHMARK_TEMPLATE_F and BENCHMARK_TEMPLATE_DEFINE_F + BENCHMARK_REGISTER_F (#1815)
* Clarify BENCHMARK_REGISTER_F

Add comments highlighting the difference between `BENCHMARK_TEMPLATE_F` and `BENCHMARK_TEMPLATE_DEFINE_F`, mirroring those of `BENCHMARK_F ` and `BENCHMARK_DEFINE_F`.

* More informative comments.

* Update user_guide.md
2024-07-16 09:51:56 +01:00
Roman Lebedev e990563876 Add BENCHMARK_TEMPLATE[12]_CAPTURE, fusion of BENCHMARK_CAPTURE and BENCHMARK_TEMPLATE (#1747)
Test coverage isn't great, but not worse than the existing one.

You'd think `BENCHMARK_CAPTURE` would suffice,
but you can't pass `func<targs>` to it (due to the `<` and `>`),
and when passing `(func<targs>)` we get issues with brackets.
So i'm not sure if we can fully avoid this helper.

That being said, if there is only a single template argument,
`BENCHMARK_CAPTURE()` works fine if we avoid using function name.
2024-01-30 12:44:36 +00:00
Roman Lebedev ea71a14891 Docs: reducing_variance.md: proofreading, fix typos (#1736) 2024-01-10 09:37:39 +00:00
FantasqueX a6b78ef168 Change Fixture to use non-const SetUp and TearDown in example (#1723)
Const SetUp and TearDown were deprecated in https://github.com/google/benchmark/pull/285

Co-authored-by: dominic <510002+dmah42@users.noreply.github.com>
2024-01-05 10:35:20 +00:00
Nicholas Junge 3623765dd3 Add setuptools_scm for dynamic zero-config Python versioning (#1690)
* Add `setuptools_scm` for dynamic zero-config Python versioning

This removes the need for manually bumping versions in the Python
bindings.

For the wheel uploads, the correct semver version is inferred in the case
of tagged commits, which is exactly the case in GitHub CI.

The docs were updated to reflect the changes in the release workflow.

* Add separate version variable and module, use PEP484-compliant exports

This is the best practice mentioned in the `setuptools_scm` docs, see
https://setuptools-scm.readthedocs.io/en/latest/usage/#version-at-runtime.
2023-11-01 09:48:01 +00:00
dominic fe1ca332a8 add logo to github pages 2023-08-21 14:31:58 +01:00
Dominic Hamon 9ba2af8d52 add black icon 2023-08-21 14:29:55 +01:00
dominic 87169dd3f5 remove logo from generated docs 2023-08-21 14:25:30 +01:00
Dominic Hamon 72938cc1c5 adding a logo to the docs 2023-08-21 14:21:07 +01:00
देवांश वार्ष्णेय b5aade1810 Update tools.md for missing color meaning issue #1491 (#1624)
Update tools.md with more documentation about U-test

Fixes https://github.com/google/benchmark/issues/1491
2023-07-09 19:25:34 +03:00
Andy Christiansen aacf2b1af9 Add support for bzlmod (excluding Python bindings) (#1615)
* Migrate to bzlmod

* Update Python version to PY3, as indicated by the actual source file.

* Migrate more libraries & first draft of direct pywheel rule usage in Bazel

* Integrate with nanobind and libpfm

* Make Python toolchain a dev dependency

* Undo py_wheel usage until later

* Added support for bzlmod for C++ parts of google_benchmark.

* Make //tools:all buildable with --enable_bzlmod

---------

Co-authored-by: Andy Christiansen <achristiansen@google.com>
2023-06-27 13:03:39 +01:00
Pavel Novikov 4b13b3d47a Fixed a typo in docs (#1600) 2023-05-15 10:07:00 +01:00
dominic 46d3c84518 Convert uses of const char* to std::string (#1567)
* Convert uses of const char* to std::string

* fix sanitizer builds

* reformat user guide

* include python bindings

* clang-format
2023-03-14 13:10:27 +00:00
Marcel Jacobse f23fedbbf8 Fix examples in user guide using deprecated DoNotOptimize-API (#1568)
* Update AUTHORS/CONTRIBUTORS

* Fix examples with deprecated DoNotOptimize API

The const-reference API to DoNotOptimize was deprecated with #1493. Some
examples in the user guide are using exactly that deprecated interface.
This fixes that by passing non-const lvalues instead. Fixes #1566
2023-03-07 14:47:03 +00:00
Carlos O'Ryan b111d01c1b cleanup: support CMake >= 3.10 (#1544)
* cleanup: support CMake >= 3.10

This aligns the project with the CMake support policies in:

https://opensource.google/documentation/policies/cplusplus-support

I also simplied the management of CMake policies. Most of the overriden
policies (anything <= CMP0067) are enabled by default when you require
CMake >= 3.10.  But it is easier to just declare that you will accept
newer policies when they are available using the `...3.22` notation.

* Address review comments

* inlined links

---------

Co-authored-by: dominic <510002+dmah42@users.noreply.github.com>
2023-02-17 13:38:53 +00:00
dominic 94083ca441 remove best effort support for ubuntu 18.04 (#1537)
* remove deprecated ubuntu-18.04 target

* update docs

* force an apt update for perfcounters
2023-02-06 15:37:26 +00:00
dominic 1318865305 try disabling liquid for jekyll to fix curly braces (#1536)
* try disabling liquid for jekyll to fix curly braces

* do it properly with commented out tags
2023-02-06 14:01:16 +00:00
SunBlack fe65457e80 Fix typos found by codespell (#1519) 2023-01-10 12:25:32 +00:00
Dominic Hamon fe5a386b40 add more docs to index 2022-12-19 12:35:00 +00:00
Raghu Raja 398a8ac2e8 [bazel] Build libpfm as a dependency to allow collection of perf counters (#1408)
* Build libpfm as a dependency to allow collection of perf counters

This commit builds libpfm using rules_foreign_cc and lets the default
build of the benchmark library support perf counter collection without
needing additional work from users.

Tested with a custom target:

```
bazel run \
        --override_repository=com_github_google_benchmark=/home/raghu/benchmark \
        -c opt :test-bench -- "--benchmark_perf_counters=INSTRUCTIONS,CYCLES"
Using profile: local

<snip>

----------------------------------------------------------------------
Benchmark            Time             CPU   Iterations UserCounters...
----------------------------------------------------------------------
BM_Test      0.279 ns        0.279 ns   1000000000 CYCLES=1.00888 INSTRUCTIONS=2

```

Signed-off-by: Raghu Raja <raghu@enfabrica.net>

* Adding myself to the CONTRIBUTORS file per CLA guidance

Enfabrica has already signed a corporate CLA.

Signed-off-by: Raghu Raja <raghu@enfabrica.net>

Signed-off-by: Raghu Raja <raghu@enfabrica.net>
2022-10-31 11:03:59 +00:00
Dominic Hamon 49aa374da9 bump cmake dep and docs (#1468)
* bump cmake dep and docs
2022-09-14 15:11:37 +01:00
Matt Armstrong 1c26d8a337 Discuss sources of variance in the user guide (#1481)
* Discuss sources of variance in the user guide

* Mention cpufreq/boost

* Pull variance material into a new document

Add reducing_variance.md as a place to discuss things related to variance
and, in the future, statistical interpretation of benchmark results.

Co-authored-by: Dominic Hamon <dominichamon@users.noreply.github.com>
2022-09-09 15:41:10 +01:00
Dominic Hamon 1531ee0d63 Correct typo in Passing Arguments section
fixes #1419
2022-07-07 14:59:15 +01:00
Tom Cobley 7280499e8e Remove redundant formatting tags (#1420) 2022-06-28 10:16:28 +01:00
Dominic Hamon b7afda2cd2 Revert "Add possibility to ask for libbenchmark version number (#1004) (#1403)" (#1417)
This reverts commit efadf67a12.
2022-06-20 17:52:03 +01:00