* 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
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
* 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>
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
* 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.
* `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.
* 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.
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>
* 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
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.
* 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.
* 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>
* 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
* 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>
* 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>
* 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>