Commit Graph

1566 Commits

Author SHA1 Message Date
Alecto Irene Perez 0c998f7cc4
Fix spurious warning 'misc-use-anonymous-namespace' (#1860) (#1861)
Disables 'misc-use-anonymous-namespace' for usage of the BENCHMARK
macro. This warning is spurious, and the variable declared by the
BENCHMARK macro can't be moved into an annonymous namespace.

We don't want to disable it globally, but it can be disabled locally,
for the `BENCHMARK` statement, as this warning appears downstream for
users.

See:
https://clang.llvm.org/extra/clang-tidy/#suppressing-undesired-diagnostics
2024-10-11 01:02:36 +03:00
Devon Loehr 24e0bd827a
Add enum value from newest Windows SDK (#1859)
* Add enum value from newest Windows SDK

Windows SDK version 10.0.26100.0 adds a cache type value, `CacheUnknown`. This adds a case for that type to `sysinfo.cc`, which will otherwise complain about the switch statement being non-exhaustive when building with the new SDK.

Since the value doesn't exist in prior SDK versions, we only add the case conditionally. The condition can be removed if we ever decide to bump up the required SDK version.

* Fix SDK version macro

Make sure the version macro we're using for the SDK is properly indicative of version 10.0.26100.0. Also fix formatting complains from the linter.

* Add space to satisfy formatter

Formatter insists on two space before a comment after a macro...

* Change preprocessor condition

Try detecting the current SDK version in a slightly different way.

* Replace NTDDI_WIN11_GE with its value

Undefined constants are treated as 0 by the preprocessor, which causes the check to trivially return true for previous SDK versions. Replace the constant with its value (from the newest SDK version) instead,
2024-10-02 09:40:03 +01:00
Alfredo Daniel Esponda Cervantes 23d8c1e589
Version string correction in pkg-config files (#1858)
Co-authored-by: Alfredo Daniel Esponda Cervantes <92197886+DanEC1211@users.noreply.github.com>
2024-09-26 17:56:16 +01:00
Dominic Hamon 3fd1e6a7ae add dry run docs 2024-09-13 10:06:24 +01:00
dominic 72ecc4ea67
Added the functionality for a dry run benchmark called through the cli argument --benchmark_dry_run. (#1851)
* Added benchmark_dry_run boolean flag to command line options

* Dry run logic to exit early and override iterations, repetitions, min time, min warmup time

* Changeddry run override logic structure and added dry run to context

---------

Co-authored-by: Shaan <shaanmistry03@gmail.com>
Co-authored-by: Shaan Mistry <49106143+Shaan-Mistry@users.noreply.github.com>
2024-09-12 15:50:52 +01:00
Richard Cole 08fdf6eb84
enable the /MP MSVC compiler argument for parallel compilation (#1846) 2024-09-05 22:28:43 +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
Igor Zhukov c19cfee61e
Fix C4459: Rename a function parameter `profiler_manager` to avoid hiding the global declaration. (#1839)
* Fix C4459: Rename a function parameter `profiler_manager` to avoid hiding the global declaration.

* Treat warnings as errors for MSVC

* disable one warning for MSVC
2024-08-19 06:39:37 +03:00
Chris Kennelly 6126d2a205
Align benchmark::State to a cacheline. (#1230)
* Align benchmark::State to a cacheline.

This can avoid interference with neighboring objects and stabilize
benchmark results.

* separate cachline definition from alignment attribute macro

Co-authored-by: Roman Lebedev <lebedev.ri@gmail.com>

---------

Co-authored-by: dominic <510002+dmah42@users.noreply.github.com>
Co-authored-by: Roman Lebedev <lebedev.ri@gmail.com>
2024-08-16 16:10:18 +01:00
Alex Bilger 437fea4b54
Fix Python manual timing example (#1722)
According to the user guide, when manual timing, it is necessary to explicit it by using the `UseManualTime` function. Its equivalent in Python is use_manual_time(). This function was not called in the example.

It is possible to verify that the use of this function has an impact on the measure by adding another `time.sleep(0.01)` at the end of the iteration. There is a x2 difference depending on whether `use_manual_time()` is used or not.

Co-authored-by: dominic <510002+dmah42@users.noreply.github.com>
2024-08-16 15:32:48 +01:00
Dominic Hamon ec3dc37b60 separate wheel versions in an effort to avoid timeouts 2024-08-16 11:56:56 +01:00
Dominic Hamon 12235e2465 v1.9.0 2024-08-16 11:08:15 +01:00
dominic a008bf82f4
Ensure reported Time is walltime by removing spurious scaling by threads (#1836)
* change the default to not scale
2024-08-13 18:12:02 +01:00
Ikko Eltociear Ashimine b884717437
chore: update perf_counters.cc (#1831)
peformance -> performance
2024-08-05 10:05:40 +01:00
mosfet80 ef73a30083
Update clang-format-lint-action (#1829)
Colorize output in github action

Co-authored-by: dominic <510002+dmah42@users.noreply.github.com>
2024-08-02 11:06:00 +01:00
mosfet80 7971a63070
Cache upd (#1830)
* Update bazel.yml

switch to node20 updated  actions/cache to v4

* Update pre-commit.yml

switch to node20 updated  actions/cache to v4
2024-08-02 10:56:57 +01:00
xdje42 ebb5e3922d
Move ProfilerManager Start/Stop routines closer to actual benchmark #1807 (#1818)
Previously, the Start/Stop routines were called before the benchmark function
was called and after it returned. However, what we really want is for them
to be called within the core of the benchmark:

  for (auto _ : state) {
    // This is what we want traced, not the entire BM_foo function.
  }
2024-08-01 08:42:41 +01:00
Nicholas Junge 25e5c52a11
Bump nanobind-bazel to v2.1.0, add stubgen target (#1824)
Adds a stub file for the `google_benchmark._benchmark` submodule,
generated with the new `nanobind_stubgen` rule released in nanobind_bazel
v2.1.0.

Tweaks the setup.py logic a little bit to package stub files with the
rest of the build artifacts. Also explicitly adds the generated stub and
marker files to the list of package data artifacts.

Co-authored-by: dominic <510002+dmah42@users.noreply.github.com>
2024-07-30 15:49:33 +01:00
mosfet80 ac80572f17
Update nanobind into benchmark_deps.bzl (#1826)
* Update nanobind into benchmark_deps.bzl

* Update benchmark_deps.bzl
2024-07-30 15:05:08 +01:00
mosfet80 cfb7e0a330
Update libs into .pre-commit-config.yaml (#1825) 2024-07-30 14:09:31 +01:00
dominic 378fe693a1
Use log2 now that NDK requires at least API 21 which includes it. (#1822)
Fixes #1820
2024-07-24 14:25:32 +01:00
Devon Loehr fa236ed6e6
Suppress invalid-offsetof warning for clang (#1821)
For several compilers, `benchmark.cc` suppresses a warning regarding its use of `offsetof`. This merely extends that suppression to cover clang as well.
2024-07-24 13:12:04 +01:00
Nicholas Junge df44bf7187
Revert to token authentication for PyPI wheel uploads (#1819)
Until the PyPI account is recovered, it should be possible to upload
wheels with the GitHub secrets that were previously used.

Changes the PyPI upload action sourcing to point to the v1 stable release
branch, which receives rolling updates and is the canonical way of
including the wheel publishing action.

Uploading will probably need another release, because setuptools_scm
needs to produce a clean tag that the PyPI API allows as an upload.
2024-07-23 14:49:06 +01:00
Peter Hawkins 64b5d8cd11
Update benchmark Python bindings for nanobind 2.0, and update to nanobind 2.0. (#1817)
Incorporates the nanobind_bazel change from https://github.com/google/benchmark/pull/1795.

nanobind 2.0 reworked the nanobind::enum_ class so it uses a real Python enum or intenum rather than its previous hand-rolled implementation.
https://nanobind.readthedocs.io/en/latest/changelog.html#version-2-0-0-may-23-2024

As a consequence of that change, nanobind now checks when casting an integer to a enum value that the integer corresponds to a valid enum. Counter::Flags is a bitmask, and many combinations are not valid enum members.

This change:
a) sets nb::is_arithmetic(), which means Counter::Flags becomes an IntEnum that can be freely cast to an integer.
b) defines the | operator for flags to return an integer, not an enum, avoiding the error.
c) changes Counter's constructor to accept an int, not a Counter::Flags enum. Since Counter::Flags is an IntEnum now, it can be freely coerced to an int.

If https://github.com/wjakob/nanobind/pull/599 is merged into nanobind, then we can perhaps use a flag enum here instead.
2024-07-18 16:54:02 +01:00
Dominic Hamon a6ad7fbbdc preparing for v1.8.5 2024-07-18 11:13:04 +01:00
Dominic Hamon ad2b1c9ed1 clang format yet again 2024-07-17 16:49:12 +01:00
Dominic Hamon 4b184d47a4 update actions/checkout to v4 2024-07-17 16:47:54 +01:00
Dominic Hamon 44507bc91f another reversal of something that breaks on wasm 2024-07-17 16:39:15 +01:00
Dominic Hamon 299a8b881d clang format header fixes 2024-07-17 13:27:41 +01:00
Dominic Hamon 99410f400c clang-format fixes 2024-07-17 13:25:16 +01:00
Dominic Hamon a73c039b1d roll back fatal error that breaks some platform (wasm) expectations 2024-07-17 13:18:38 +01:00
Dominic Hamon 65668db273 revert perf counters change until we can do the full version 2024-07-16 17:45:30 +01:00
Dominic Hamon 14ddd77a90 remove old travis config 2024-07-16 17:39:51 +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
dominic 38df9daf48
add PERF_FORMAT_TOTAL_TIME_{ENABLED,RUNNING} to support multiplexing (#1814) 2024-07-12 10:28:16 +01:00
Chris Cotter 71f4218c1a
Add -lkstat to the .pc for Solaris (#1801)
* Add -lkstat to the .pc for Solaris

This fixes linking for projects that rely on pkg-config to generate the
link line on Solaris.

Test plan: Built the project locally on Solaris and verified -kstat
appears in the .pc file

```
$ cat lib/pkgconfig/benchmark.pc  | grep Libs.private
Libs.private: -lpthread -lkstat
```

* Use BENCHMARK_PRIVATE_LINK_LIBRARIES
2024-07-03 21:16:43 +03:00
Stephen Nicholas Swatman c2146397ac
Find libpfm dependency in installed CMake configs (#1806)
Currently, Google Benchmark can be built and installed with support for
libpfm, but this can cause a problem if that installation is later
called upon by another CMake project. Indeed, while the installed CMake
configuration script correctly identifies that it needs to link against
libpfm, it doesn't try to find libpfm, meaning that the target will be
unavailable. This commit fixes this potential configuration-time error
by ensuring that an installation of Google Benchmark will correctly try
to find the libpfm dependency when it is used elsewhere.
2024-06-19 21:03:42 +03:00
Alexander Karatarakis 447752540c
[bazel] Use `includes` instead of `strip_include_prefix` (#1803)
When using `includes`, consumers will apply the headers
using `-isystem`, instead of `-I`. This will allow diagnostics
of consumers to not apply to `benchmark`.

More info:

https://bazel.build/reference/be/c-cpp#cc_library.includes

https://bazel.build/reference/be/c-cpp#cc_library.strip_include_prefix

gtest uses `includes` as well:
1d17ea141d/BUILD.bazel (L120)
2024-06-17 09:38:32 +01:00
Khem Raj 8e1823d6f5
cycleclock: Fix type conversion to match function return type on riscv64 (#1802)
Fixes builds with clang

src/cycleclock.h:213:10: error: implicit conversion changes signedness: 'uint64_t' (aka 'unsigned long') to 'int64_t' (aka 'long') [-Werror,-Wsign-conversion]
     213 |   return cycles;
         |   ~~~~~~ ^~~~~~
   1 error generated.
2024-06-11 13:37:35 +01:00
Robert Schulze 2fa4b26e58
Bump minimum required C++ version from C++11 to C++14 (#1800) 2024-06-10 11:08:49 +01:00
dominic 10199fb48e
bump standard to C++14 (#1799)
* update requirements to point to our dependencies doc

* bump standard to c++14
2024-06-07 15:22:45 +01:00
Khem Raj 7f0e99af54
cycleclock: Fix type conversion to match function return type (#1794)
fixes build with clang19

src/cycleclock.h:208:52: error: implicit conversion changes signedness: 'uint64_t' (aka 'unsigned long long') to 'int64_t' (aka 'long long') [-Werror,-Wsign-conversion]
  208 |   return (static_cast<uint64_t>(cycles_hi1) << 32) | cycles_lo;
      |   ~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
1 error generated.
2024-05-29 06:14:54 +03:00
Roman Lebedev d77b692710
CMake: unbreak version handling for tarballs (#1793)
#1742 changed the placeholder version from `0.0.0` to `v0.0.0`,
but this line which was further dealing with it, was not updated.

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

Co-authored-by: dominic <510002+dmah42@users.noreply.github.com>
2024-05-28 11:24:21 +01:00
Nicholas Junge 144d23cf5f
hotfix: Correct pypi-publishing action tag to v1.8.14 (#1791)
Also bump pre-commit dependencies via `pre-commit autoupdate`.
2024-05-24 09:51:41 +01:00
Steven Johnson 7f992a553d
Improve compatibility with Hexagon hardware (#1785)
The customization done via BENCHMARK_OS_QURT works just fine with the Hexagon simulator, but on at least some Hexagon hardware, both `qurt_timer_get_ticks()` and `std::chrono::now()` are broken and always return 0. This fixes the former by using the better-supported (and essentially identical `qurt_sysclock_get_hw_ticks()` call, and the latter by reading a 19.2MHz hardware counter (per suggestion from Qualcomm). Local testing seems to indicate these changes are just as robust under the simulator as before.
2024-05-23 20:08:54 +03:00
dominic a4cf155615
preparing for v1.8.4 (#1788) 2024-05-23 15:02:46 +01:00
Nicholas Junge bc946b919c
Modernize wheel building job config (#1783)
It is now possible to build Mac wheels on native machines in Github
Actions, so ARM64 Mac wheels are now built and tested on M1 machines.

Also, the artifact up-/download was migrated to v4, which made it
necessary to upload wheels to unique artifact names, and then later
stitch them together again in a subsequent job.

The cross-platform Mac build injection in setup.py was removed,
since it is no longer necessary.

I relanded a monkey-patching of Bazel build files, this time for
MODULE.bazel. This is because `rules_python` does not allow running
as the root user, which is the case in cibuildwheel+Linux (happens
in a Docker container). Since I did not see a quick way of switching
to rootless containers, and did not want to hardcode the config change
(it can apparently cause cache misses and build failures), I inject the
"ignore_root_user_error" flag into the MODULE.bazel file when running
in cibuildwheel on Linux.
2024-04-15 17:44:09 +01:00
Nicholas Junge 185c55d793
Switch git override to stable BCR tag for nanobind_bazel (#1778)
This comes following the first BCR release of nanobind_bazel.

Feature-wise, nothing substantial has changed, except that the extensions
are stripped of debug info when built in release mode, which reduces
clutter in the symbol tables.

No stubgen yet, since nanobind v2 has not been released yet.
2024-04-15 10:57:02 +01:00
David Seifert c0105603f6
Add `benchmark_main.pc` to link `main()` containing library (#1779)
This is similar to the addition in 8604c4adac (diff-eb8e49bdf5e9aafb996777a4f4302ad1efd281222bf3202eb9b77ce47496c345)
that added pkg-config support in GTest. Without this, users
need to manually find the library containing `main()`.
2024-04-14 19:05:36 +03:00