Commit Graph

1567 Commits

Author SHA1 Message Date
Nicholas Junge cb39b7150d
Bump `nanobind` to stable v1.4.0 tag (#1626)
This seems to reduce binding sizes even further, with a wheel size of
175KB on my local machine (macOS 13.4.1).
2023-07-11 09:56:51 +01:00
Dominic Hamon a092f8222c missing cmake include 2023-07-10 17:58:01 +01:00
Dominic Hamon c30468bb4b add back package properties for PFM 2023-07-10 17:54:09 +01:00
Pichot 8805bd0c14
pfm: Use a more standard CMake approach for finding libpfm (#1628)
* pfm: Use a more standard CMake approach for finding libpfm

* add myself and sort AUTHORS & CONTRIBUTORS
2023-07-10 17:46:34 +01:00
Nicholas Junge 16c6ad83aa
Add pyproject.toml file for PEP518 compliance (#1625)
The newly created `pyproject.toml` contains all static metadata as well
as the readme and version as dynamic arguments, to be read by setuptools
during the build.

What is left in the `setup.py` for now is the custom Bazel extension
class, since that is not properly supported yet.
2023-07-10 10:43:49 +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 4931aefb51
Fix broken PFM-enabled tests (#1623)
* Add pfm CI actions for bazel

* Fix problems in unit test.

* Undo enabling the CI tests for pfm - github CI machines seemingly do not support performance counters.

* Remove commented code - can be revisited in github history when needed, and there's a comment explaining the rationale behind the new test code.

---------

Co-authored-by: Andy Christiansen <achristiansen@google.com>
Co-authored-by: dominic <510002+dmah42@users.noreply.github.com>
2023-07-07 09:58:16 +01:00
Dominic Hamon 015d1a091a bump version to 1.8.2 ready for release 2023-07-06 09:50:35 +01:00
Enrico Seiler e730f91d8c
Fix passing non-const lvalue refs to DoNotOptimize (#1622) 2023-07-05 18:05:08 +01:00
Chinmay Dalal 43b2917dce
Add more terminals with color support (#1621) 2023-07-04 16:13:55 +01:00
dominic 408f9e0667
Add discord server link to README 2023-07-04 08:55:37 +01:00
Dominic Hamon daa12bcc5a bump version to 1.8.1 pre release 2023-07-04 08:48:07 +01:00
Roman Lebedev edb0d3d46d
Suppress intentional potential memory leak as detected by clang static analysis (#1618)
https://github.com/google/benchmark/issues/1513

Co-authored-by: dominic <510002+dmah42@users.noreply.github.com>
2023-07-03 10:18:31 +01:00
Andy Christiansen fed73374d7
Add a CI test for the new bzlmod integration (#1617)
* Test bzlmod build workflow for Bazel


---------

Co-authored-by: Andy Christiansen <achristiansen@google.com>
2023-07-03 09:59:56 +01: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
Gary Miguel 1d25c2e3be
remove old-style (C-style) casts (#1614)
Remove old-style (C-style) casts

This is required by the Google C++ style guide:
https://google.github.io/styleguide/cppguide.html#Casting
2023-06-22 01:35:44 +03:00
Chilledheart b323288cba
Fix a typo in regex choice (#1610)
BENCHMARK_HAVE_STD_REGEX is not used but HAVE_STD_REGEX like the other two choices, i.e. HAVE_GNU_POSIX_REGEX and HAVE_POSIX_REGEX.

Co-authored-by: dominic <510002+dmah42@users.noreply.github.com>
2023-06-19 08:51:48 +01:00
Bulat Gaifullin df9a99d998
Fix pass rvalue to DoNotOptimize (#1608)
* Fix pass rvalue to DoNotOptimize #1584

* Add test
2023-06-19 08:35:52 +01:00
Dominic Hamon 604f6fd3f4 Add project name to version message
Inspired by paulcaprioli
2023-05-30 08:44:26 +01:00
Pavel Novikov 4b13b3d47a
Fixed a typo in docs (#1600) 2023-05-15 10:07:00 +01:00
Andy Christiansen bb9aafaa6c
Update Python version to PY3, as indicated by the actual source file. (#1598)
Co-authored-by: Andy Christiansen <achristiansen@google.com>
2023-05-11 09:18:18 +01:00
Vy Nguyen fec77322b4
Fix code triggering -Wsign-conversion (#1596)
* Fix code triggering -Wsign-conversion

* more test
2023-05-11 08:40:05 +01:00
Andy Christiansen 318dd44225
Disable debug-only test in release builds to avoid expected failures. (#1595)
Co-authored-by: Andy Christiansen <achristiansen@google.com>
2023-05-10 10:18:43 +01:00
Dominic Hamon 2dd015dfef update version to v1.8.0 2023-05-05 11:25:54 +01:00
dominic fba5dd147d
reenable msan sanitizer workflow (#1589) 2023-05-03 16:55:45 +01:00
Andrii Dushko b177433f3e
Guard NOMINMAX to prevent redefinition error (#1581) (#1582)
Fixes #1581.
2023-03-31 00:17:14 +03:00
Shiqing Yan f7547e29cc
Correct libpfm dep for integrators. (#1579) 2023-03-20 09:50:17 +00:00
pkasting d29044d5da
Fix compile warnings about ignoring a [[nodiscard]] type. (#1577)
Co-authored-by: dominic <510002+dmah42@users.noreply.github.com>
2023-03-16 11:07:13 +00:00
Dominic Hamon 4b086c26fe make libpfm dep work for integrators 2023-03-16 10:16:23 +00:00
Dominic Hamon 0c34d812e4 use 'new_git_repository' in external deps call to work with older bazel versions 2023-03-16 09:49:12 +00:00
dominic efc89f0b52
link to benchmark directly for tests that aren't link_main_test (#1576) 2023-03-14 13:35:32 +00: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
dominic 68aa1903b1
add '@' to correctly reference build file for libpfm (#1575) 2023-03-14 10:18:00 +00:00
Henrique Bucher 9f7dc386be
Address warnings on NVIDIA nvc++ (#1573)
* Address warnings on NVIDIA nvc++

Types of warnings were being generated:
1. Deprecated warnings - solved by defining the relevant BENCHMARK_*
  macros for nvc++ and adding pragma suppress on a couple of .cc files
2. Setup/TearDown const vs non-const partial override - solved by
   adding non-const version
3. Static but not referenced - added diagnostic suppress for that file

* Modified manually to comply with CD/CI

* Revert partial override

* Suppress warnings from tests if compiler is NVHPC

---------

Co-authored-by: dominic <510002+dmah42@users.noreply.github.com>
2023-03-13 12:34:12 +00:00
Dominic Hamon 1b507cbf10 simplify setting C++ standard 2023-03-11 14:09:45 +00:00
Mike Apodaca f32748c372
[FR] Provide public accessors to benchmark name and arguments #1551 (#1563)
* [FR] Provide public accessors to benchmark name and arguments #1551

* Update AUTHORS and CONTRIBUTORS

* Update benchmark_register.cc

* Fix lint formatting
2023-03-10 12:38:11 +00:00
dominic 060d762d61
use std::string for skip messages (#1571) 2023-03-08 18:57:19 +00:00
Mike Apodaca adb0d3d0bf
[FR] state.SkipWithMessage #963 (#1564)
* Add `SkipWithMessage`

* Added `enum Skipped`

* Fix: error at end of enumerator list

* Fix lint errors

---------

Co-authored-by: dominic <510002+dmah42@users.noreply.github.com>
2023-03-08 18:24:48 +00:00
Henrique Bucher 4050b4bda5
Fix build break with nvc++ when -Werror is ON (#1569)
Build breaks when -Werror is turned on because of unhandled cases of
inocuous/pedantic warnings. Adopted the same solution as for Intel PGI
compiler - just disable -Werror manually, unless BENCHMARK_FORCE_WERROR
is enabled. Fixes #1556.
2023-03-08 09:50:30 +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
Nicholas Junge 23dadfa4a7
Bump nanobind to stable v0.2.0, change linker options (#1565)
Bumps nanobind to v0.2.0, the latest stable version to include all
features needed to create the GBM bindings. Deprecated names in v0.2.0
were migrated to their new counterparts.

Linkopts for macOS were changed to mirror the "endorsed" linker options
used in nanobind's CMake config, which were changed since the last
commit.
2023-03-07 11:22:00 +00:00
Henrique Bucher fbc6efa9b5
Refactoring of PerfCounters infrastructure (#1559)
* Refactoring of PerfCounters infrastructure

The main feature in this pull request is the removal of the static
sharing of PerfCounters and instead creating them at the top
`RunBenchmarks()`  function where all benchmark runners are created. A
single PerfCountersMeasurement object is created and then shared with
all the new BenchmarkRunners objects, one per existing benchmark.

Other features conflated here in this PR are:
- Added BENCHMARK_DONT_OPTIMIZE macro in global scope
- Removal of the `IsValid()` query, being replaced by checking the
  number of remaining counters after validity tests
- Refactoring of all GTests to reflect the changes and new semantics
- extra comments throughout the new code to clarify intent

It was extremely hard to separate all those features in different PRs
as requested since they are so interdependent on each other so I'm just
pushing them altogether and asking for forgiveness.

This PR comes replacing PRs 1555 and 1558 which have been closed.

* Fixed whitespace issue with clang-format

My clang-format insists in deleting this single white space on line 601
while Github's clang format breaks when it is added. I had to disable
format-on-save to check-in this revert change.
I'm using clang 14.0.6.
2023-03-07 10:27:52 +00:00
dominic 9885aefb96
get rid of warnings in tests (#1562) 2023-03-06 14:47:54 +00:00
Henrique Bucher 2d5012275a
Filter performance counter names, not invalidate all (#1554)
* Filter performance counter names, not invalidate all

Currently, the performance counters are validated while they
are being created and one failure returns NoCounters(), ie it
effecitvely invalidates all the counters.

I would like to propose a new behavior: filter instead. If an
invalid name is added to the counter list, or if that particular
counter is not supported on this platform, that counter is dropped
from the list and an error messages is created, while all the
other counters remain active.

This will give testers a peace of mind that if one mistake is made
or if something is changed or removed from libpfm, their entire
test will not be invalidated. This feature gives more tolerance
with respect to versioning.

Another positive is that testers can now input a superset of all
desired counters for all platforms they support and just let
Benchmark drop all those that are not supported, although it will
create quite a lot of noise down the line, in which case perhaps
we should drop silently or make a consolidated, single error line
but this was not implemented in this change set.

* Removed unused helper type.
2023-03-02 14:56:13 +00:00
Henrique Bucher 27c1d8ace9
Implement unlimited number of performance counters (#1552)
* Implement unlimited number of performance counters

Linux performance counters will limit the number of hardware
counters per reading group. For that reason the implementation of
PerfCounters is limited to 3. However if only software counters
are added, there is no reason to limit the counters. For hardware
counters, we create multiple groups and store a vector or leaders
in the PerfCounters object. When reading, there is an extra time
waste by iterating through all the group leaders. However this
should be the same performance as with today. Reading is done by
groups and it had to be heavily adjusted with the logic being
moved to PerfCounterValues. I created a test for x86-64 and took
care of filtering out the events in case it runs in a platform
that does not support those counters - the test will not fail. The
current tests were already failing (ReOpenExistingCounters,
CreateExistingMeasurements and MultiThreaded) on the main branch
and they continue to fail after this implementation - I did not
fix those not to conflate all here.

* Moved the PerfCounterValues::Read() implementation from header to body.

* Added missing implementation of PerfCounters::IsCounterSupported when HAVE_LIBPFM is not defined.

* Changed comments to reflect the implementation

* Removed arg name so it does not generate an error when HAVE_LIBPBM is not defined.

* Made loop counter a const reference for clang-tidy

* Added missig BENCHMARK_EXPORT to PerfCounterValues
2023-03-01 15:30:41 +00:00
dominic c71d040549
add compiler to build-and-test and create min-cmake CI bot (#1550)
* add compiler to build-and-test and create min-cmake CI bot

* fix CXX env var

* downgrade msvc generator for cmake-3.10

* assume windows users have the latest cmake
2023-02-28 12:40:40 +00:00
Yingwei Zheng 3b19d7222d
Fix CPU frequency estimation on riscv (#1549)
* Fix CPU frequency estimation on riscv

* Cleanup code for CPU frequency estimation

* Fix use before definition of the macro

* Move the platform definitions back

* Fix compilation error on windows

* Remove unused sleep.h and sleep.cc
2023-02-21 11:30:28 +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 1079d96989
Werror all the time (#1546) 2023-02-16 18:54:09 +00:00
Jonathon Reinhart 07996a8adc
Add missing parentheses in ParseBenchMinTime() (#1545)
The previous code was triggering a warning in Debug builds where NDEBUG
is not defined and BM_CHECK() is included:

  benchmark/src/benchmark_runner.cc: In function ‘benchmark::internal::BenchTimeType benchmark::internal::ParseBenchMinTime(const std::string&)’:
  benchmark/src/benchmark_runner.cc:212:24: error: suggest parentheses around ‘&&’ within ‘||’ [-Werror=parentheses]
    212 |            (has_suffix && *p_end == 's' || *p_end == '\0'))
        |             ~~~~~~~~~~~^~~~~~~~~~~~~~~~
  benchmark/src/check.h:82:4: note: in definition of macro ‘BM_CHECK’
     82 |   (b ? ::benchmark::internal::GetNullLogInstance()                           \
        |    ^

Add parenthesis around the && expression.

Also fix a spelling error and move the comma in the preceding comment to
improve clarity.

Tested:
- cmake -E make_directory build
- cmake -E chdir "build" cmake -DBENCHMARK_DOWNLOAD_DEPENDENCIES=on -DCMAKE_BUILD_TYPE=Debug ../
- cmake --build "build" --config Debug
- cmake -E chdir "build" ctest --build-config Debug
2023-02-16 18:35:21 +00:00