Commit Graph

1447 Commits

Author SHA1 Message Date
Mészáros Gergely
c9106a79fa
Audit MSVC references in cmake files to consider clang++ (#1669)
There are three major compilers on Windows targeting the MSVC ABI (i.e.
linking with microsofts STL etc.):
  - `MSVC`
  - `clang-cl` aka clang with the MSVC compatible CLI
  - `clang++` aka clang with gcc compatible CLI

The cmake variable `MSVC` is only set for the first two as it defined in
terms of the CLI interface provided:

> Set to true when the compiler is some version of Microsoft Visual
> C++ or another compiler simulating the Visual C++ cl command-line syntax.

(from cmake docs)

For many of the tests in the library its the ABI that matters not the
cmdline, so check `CMAKE_CXX_SIMULATE_ID` too, if it is `MSVC` the
current compiler is targeting the MSVC ABI. This handles `clang++`
2023-09-26 12:31:24 +01:00
Dominic Hamon
344117638c bump version to 1.8.3 2023-08-31 13:16:50 +01:00
Dominic Hamon
db3e000c1e Merge branch 'jmr-stat-median' 2023-08-25 09:59:02 +01:00
Dominic Hamon
78220d6f0d tweak comment wording 2023-08-25 09:58:30 +01:00
dominic
9f254bddf0
Merge branch 'main' into stat-median 2023-08-24 17:50:56 +01:00
Jesse Rosenstock
6dd50bb606 StatisticsMedian: Fix bug
Previously, this could return the wrong result when there
was an even number of elements.

There were two `nth_element` calls.  The second call could
change elements in `[center2, end])`, which was where
`center` pointed.  Therefore, `*center` sometimes had the
wrong value after the second `nth_element` call.

Rewrite to use `max_element` instead of the second call to
`nth_element`.  This avoids modifying the vector.
2023-08-24 16:05:09 +02:00
Jesse Rosenstock
dfc8a92abc
test: Use gtest_main only when needed (#1657)
* test: Use gtest_main only when needed

There are two types of tests.  `*_gtest.cc` files use `gtest` and
`gtest_main`.  `*_test.cc` files define their own main.

Only depend on `gtest`/`gtest_main` when needed.  This is similar
to what `CMakeLists.txt` does.

* comment-only: gunit => gtest

* Fix typo
2023-08-24 13:43:50 +01:00
Jesse Rosenstock
9c65aebb26
perf_counters: Initialize once only when needed (#1656)
* perf_counters: Initialize once only when needed

This works around some performance problems running Android under QEMU.
Calling `pfm_initialize` was very slow, and was called during dynamic
initialization (before `main` or when loaded as a shared library).
This happened whenever benchmark was linked, even if no benchmarks
were run.

Instead, call `pfm_initialize` at most once, and only when one of:
1. `PerfCounters::Initialize` is called
2. `PerfCounters::Create` is called with a non-empty counter list
3. `PerfCounters::IsCounterSupported` is called

The return value of the first `pfm_initialize()` is saved and
returned from all subsequent `PerfCounters::Initialize` calls.

* perf_counters: Make success var const

* InitLibPfmOnce: Inline function
2023-08-24 10:04:09 +01:00
Jesse Rosenstock
e73915667c
State: Initialize counters with kAvgIteration in constructor (#1652)
* State: Initialize counters with kAvgIteration in constructor

Previously, `counters` was updated in `PauseTiming()` with
`counters[name] += Counter(measurement, kAvgIteration)`.

The first `counters[name]` call inserts a counter with no flags.

There is no `operator+=` for `Counter`, so the insertion is done
by converting the `Counter` to a `double`, then constructing a
`Counter` to insert from the `double`, which drops the flags.

Pre-insert the `Counter` with the correct flags, then only
update `Counter::value`.

Introduced in 1c64a36 ([perf-counters] Fix pause/resume (#1643)).

* perf_counters_test.cc: Don't divide by iterations

Perf counters are now divided by iterations, so dividing again
in the test is wrong.

* State: Fix shadowed param error

* benchmark.cc: Fix clang-tidy error

---------

Co-authored-by: dominic <510002+dmah42@users.noreply.github.com>
2023-08-21 15:35:42 +01:00
Jesse Rosenstock
e441a8cb11
perf-counters: Make tests pass on Android (#1653)
* perf_counters_gtest: Make test pass on Android

Tested on Pixel 3 and Pixel 6.  Reduce test to the intersection of
what passes on all platforms.

Pixel 6 doesn't support BRANCHES, and only supports two perf
counters.


---------

Co-authored-by: dominic <510002+dmah42@users.noreply.github.com>
2023-08-21 15:04:50 +01: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
83939d0bd4
remove icon from main README 2023-08-21 14:24:38 +01:00
dominic
05ed7ba2a2
update logo path 2023-08-21 14:21:47 +01:00
Dominic Hamon
72938cc1c5 adding a logo to the docs 2023-08-21 14:21:07 +01:00
Jesse Rosenstock
885e9f71d6
benchmark.cc: Fix benchmarks_with_threads condition (#1651)
Change condition for `benchmarks_with_threads` from `benchmark.threads() > 0` to `> 1`.  `threads()` appears to always be `>= 1`.

Introduced in fbc6efa (Refactoring of PerfCounters infrastructure (#1559))
2023-08-17 15:41:17 +01:00
Jesse Rosenstock
aa59d40f88
sysinfo.cc: Call getloadavg for Android API >= 29 (#1) (#1649)
Support for `getloadavg` was added in API level 29.
2023-08-14 17:02:42 +01:00
Mircea Trofin
1c64a36c5b
[perf-counters] Fix pause/resume (#1643)
* [perf-counters] Fix pause/resume

Using `state.PauseTiming() / state.ResumeTiming()` was broken.

Thanks [@virajbshah] for the the repro testcase.

* ran clang-format over the whole perf_counters_test.cc

* Remove check that perf counters are 0 on `Pause`, since `Pause`/`Resume`
sequences would cause a non-0 counter value

* both upper and lower bound for the with/without resume counters

---------

Co-authored-by: dominic <510002+dmah42@users.noreply.github.com>
2023-08-11 12:46:36 +01:00
Devansh Varshney (देवांश वार्ष्णेय)
cbecc8ffc7
fix: added benchmark_counters_tabular for file (#1645)
* fix: added benchmark_counters_tabular for file

* fix: only checking the counters_tabular flag
2023-08-11 10:59:53 +01:00
Ioanna-Maria Panagou
14961f1cb6
Fix IntelLLVM compiler error (#1644)
* add -fno-finite-math-only for IntelLLVM
2023-08-10 10:33:10 +01:00
देवांश वार्ष्णेय
02a354f3f3
bug: Inconsistent suffixes console reporter 1009 (#1631)
* removed appendHumanReadable as it was not used anywhere

---------

Co-authored-by: dominic <510002+dmah42@users.noreply.github.com>
2023-08-01 08:47:09 +01:00
Andy Christiansen
6e80474e62
Mark internal deps as dev_depenencies so that downstream modules don't require those. (#1640)
Co-authored-by: Andy Christiansen <achristiansen@google.com>
Co-authored-by: dominic <510002+dmah42@users.noreply.github.com>
2023-07-31 17:23:27 +01:00
Saran Tunyasuvunakool
71ad1856fd
Fix -Werror,-Wold-style-cast build failure on Windows. (#1637)
* Fix `-Werror,-Wold-style-cast` build failure on Windows.

* Fix parentheses.

---------

Co-authored-by: dominic <510002+dmah42@users.noreply.github.com>
2023-07-31 15:14:34 +01:00
Nicholas Junge
8f7b8dd9a3
Re-enable windows-latest tests for newer Bazel (#1641)
The Windows toolchain detection fix made it into Bazel 6.3.0, so the CI
should work again with the re-enabled `windows-latest` marker.

Require Bazel 6.3.0 in the Linux container setup in `cibuildwheel`.
2023-07-31 10:51:37 +01:00
James Sharpe
27d64a2351
Update bzlmod support to new rules_python extension API (#1633)
Co-authored-by: dominic <510002+dmah42@users.noreply.github.com>
2023-07-18 08:40:54 +01:00
Nicholas Junge
c5997e0a78
Delete unused requirements file, simplify nanobind build file (#1635)
The dependencies are contained in the `pyproject.toml` since it was added.

Switches to header and source file globbing instead of manually listing
the files. The selects for different platforms are removed, as a tradeoff,
we take a single- to low double-digit hit in wheel sizes (between 5 percent
zipped and 12% installed on MacOS 13.4).
2023-07-17 15:28:35 +01:00
dominic
b1c4a752d1
Add tests for Human Readable functionality (#1632)
* Add tests for Human Readable functionality

also fix an issue where the SI/IEC unit wasn't being correctly passed
through.
2023-07-14 13:56:01 +01:00
dominic
e2556df80f
Downgrade bazel to windows-2019 (#1629)
* Downgrade bazel to windows-2019

Windows 2022 is not well supported by bazel yet:
https://github.com/bazelbuild/bazel/issues/18592

* no windows-latest, only windows-2019 (for bazel)
2023-07-12 14:46:34 +01:00
dependabot[bot]
ba49f1c167
Bump scipy from 1.5.4 to 1.10.0 in /tools (#1630)
Bumps [scipy](https://github.com/scipy/scipy) from 1.5.4 to 1.10.0.
- [Release notes](https://github.com/scipy/scipy/releases)
- [Commits](https://github.com/scipy/scipy/compare/v1.5.4...v1.10.0)

---
updated-dependencies:
- dependency-name: scipy
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-11 18:28:32 +03:00
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