Commit graph

1338 commits

Author SHA1 Message Date
Roman Lebedev db4f581fbb
Partially revert "Do not depend on unversioned python binary (#1496)" (#1501)
As predicted, the cmake part of the change is contentious.
https://github.com/google/benchmark/pull/1496#issuecomment-1276508266

This partially reverts commit 229bc5a937.
2022-10-13 10:03:29 +01:00
Matthias Braun 229bc5a937
Do not depend on unversioned python binary (#1496)
Some linux distributions no longer provide `python` binary and require
usage of `python3` instead. This changes the scripts here and uses
cmake `find_package(Python3` when running python.

Co-authored-by: Dominic Hamon <dominichamon@users.noreply.github.com>
2022-10-10 14:46:41 +03:00
rorth 12e0d70a43
Fix Solaris compilation (#1499) (#1500)
This patch fixes compilation on Solaris, addressing the problems reported
in Issue #1499:

* Provide `HOST_NAME_MAX` definition.
* Match `sysconf(3C)` return type.
* Avoid `-Wcast-qual` warnings with `libkstat(3KSTAT)` functions.
* Avoid clash with `<floatingpoint.h>` `single` typedef.
2022-10-06 09:18:55 +01:00
Marat Dukhan d2a8a4ee41
Support for QuRT OS (Hexagon RTOS) (#1497) 2022-10-04 20:43:27 +01:00
Dominic Hamon 49aa374da9
bump cmake dep and docs (#1468)
* bump cmake dep and docs
2022-09-14 15:11:37 +01:00
Nicholas Junge 9265511257
Bump pybind11 version to enable Python 3.11 wheel builds (#1489)
This commit bumps the pybind11 version to 2.10.0, which is the first
pybind version coming with Python 3.11 support. This change is necessary
to facilitate wheel builds for Python 3.11 and upward, as changes to
Python internals in 3.11 broke compatibility with older pybind11
versions.

Co-authored-by: Dominic Hamon <dominichamon@users.noreply.github.com>
2022-09-13 15:01:46 +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
Matt Armstrong becf80f3a9
Stop using pandas.Timedelta (fixes #1482) (#1483)
The pandas.Timedelta class truncates to integral nanoseconds, which throws
away sub-nanosecond precision present in benchmark JSON.  Switch to
floating point multiplication, which preserves it.

Fixes #1482
Tentatively fixes #1477.
2022-09-08 20:26:58 +03:00
Vy Nguyen db55c89f31
Eliminate usage of deprecated API in sysinfo.cc (#1474)
* Eliminate usage of deprecated  API in sysinfo.cc

The `std::wstring_convert` is deprecated in C++17.
Since this code is in the windows branch, we could use the win32 API (MultiByteToWideChar)

* ran clang-format
2022-08-30 15:32:46 +01:00
Nicholas Junge ff629d847c
Enable aarch64 Linux wheel builds, use cibuildwheel action directly (#1472)
This commit enables arm64 Linux wheel builds for Python.
It also changes the build procedure on Linux using
cibuildwheel in GitHub Actions. Instead of the more granular, verbose
approach that was used until now, we opt for the GitHub Action released
by cibuildwheel directly.

We also change the Bazel install procedure in the manylinux Docker
container image. Previously, Bazel was installed from an added RHEL repo, since that is
the recommended official way of installing Bazel on CentOS platforms.
However, the last successful build available for manylinux2014 has been Bazel 4,
which is showing its age with the release of Bazel 6 coming up as of this commit.

After this change, prebuilt Bazel binaries are downloaded using
wget directly from the Bazel GitHub release page. Since Bazel is built
for both x86 and arm64 on Linux, we immediately gain wheel build
support for these architectures. However, since the architecture
of the manylinux image is aarch64 instead of arm64,
a shell script was added that normalizes aarch64 to arm64,
and installs the correct arm64 Bazel binary if necessary.
2022-08-30 13:35:50 +01:00
AJ Heller 13196fff84
Clean up test documentation formatting (#1475) 2022-08-27 20:41:33 +03:00
babbaj 2a78e8cbe9
use CMAKE_INSTALL_FULL in pkg-config file (#1473) 2022-08-23 23:28:02 +03:00
Pavel V. Sysolyatin e8baf26225
Link error when use as static library on windows. (#1470) 2022-08-18 11:19:51 +01:00
Dominic Hamon 77d1e74d29
add debug option for enabling more output for failed cxxfeaturechecks (#1467)
fixes #1466
2022-08-10 20:42:27 +01:00
Björn Daase 4366d66385
FIx typo in benchmark.h (#1465) 2022-08-10 17:46:55 +01:00
Dominic Hamon af32e3fe1a
run ClearRegisteredBenchmarks at exit (#1463) 2022-08-08 21:34:20 +01:00
Cezary Skrzyński a476d0fd8e
Avoid deprecation warning in NVHPC (#1459)
* Avoid deprecation warning in NVHPC

* Use more general NVCC identification macro
2022-08-08 15:57:48 +01:00
Dominic Hamon 974cd5a5c5
Ensure we don't need benchmark installed to pass c++ feature checks (#1456)
* Ensure we don't need benchmark installed to pass c++ feature checks

Requires removal of some dependencies on benchmark.h from internal
low-level headers, which is a good thing.

Also added better logging to the feature check cmake module.
2022-08-04 15:33:35 +01:00
Vy Nguyen 5eb16eebb3
Explicitly cast int literals to int8_t in tests to silence implicit-conversion warnings (#1455)
* Explicitly cast int literals to int8_t in tests so silence implicit-conversion warnings

Error came from:
```
: error: implicit conversion loses integer precision: 'const int' to 'const signed char' [-Werror,-Wimplicit-int-conversion]
```

* clang format

* undo deleted line
2022-08-04 09:18:19 +01:00
Vy Nguyen 1cca1d091c
Fixed build issues on window (#1449)
* Fixed build issues on window

- Added missing dlimport/export attributes in function definitions. (They are needed in both decls and defs)
- Removed dlimport/dlexprt attribute in private field. (global_context is not exported anywhere).

* fixed incorrect include path

* undo changes w.r.t HelperPrintf

* removed forward decl of private variable - instead, introduce a getter and use it.

* Removed forward decl from benchmark_gtest too

Co-authored-by: Dominic Hamon <dominichamon@users.noreply.github.com>
2022-08-03 09:44:35 +01:00
Dominic Hamon 7d48eff772
remove unnecessary generated include directory (#1451) 2022-07-29 15:18:19 +01:00
Yuri Khan 892f29589d
Initialize help hook before actually parsing the command line (#1447) 2022-07-26 16:33:32 +01:00
Vy Nguyen 141b554e3a
Remove stray comment and added missing header (#1444)
- The export.h is no longer generated, so removed the comment.
- Added export.h to benchmark_main
2022-07-26 09:00:49 +01:00
Dominic Hamon 361e8d1cfe version bump 2022-07-25 12:35:38 +01:00
maochongxin ef7f75fb18
simplified code (#1439) 2022-07-21 12:34:02 +01:00
Dominic Hamon e27c93073f
use target_compile_definitions (#1440) 2022-07-21 11:50:01 +01:00
Dominic Hamon 7b3ac07517
Stop generating the export header and just check it in (#1435)
* Stop generating the export header and just check it in

* format the new header

* support windows

* format the header again

* avoid depending on internal macro

* ensure we define the right thing for windows static builds

* support older cmake

* and for tests
2022-07-20 20:34:39 +01:00
Dominic Hamon d845b7b3a2 Also fix the SOVERSION for benchmark_main 2022-07-19 09:14:35 +01:00
Dominic Hamon d4bc509bcd Fix SOVERSION of shared library
Fixes #1434
2022-07-18 18:19:05 +01:00
Dominic Hamon 7a2024e961 v1.6.2 bump 2022-07-18 15:34:24 +01:00
Ross McIlroy 48c2d1c1ee
Expose google_benchmark.State for python bindings. (#1430)
Allows for type annotations.
2022-07-15 18:06:53 +01:00
Cezary Skrzyński 4efcc47461
Suppress nvcc offsetof warning (#1429)
* Suppress nvcc offsetof warning

* Update AUTHORS and CONTRIBUTORS
2022-07-15 12:18:45 +01:00
Dominic Hamon 1531ee0d63
Correct typo in Passing Arguments section
fixes #1419
2022-07-07 14:59:15 +01:00
Dominic Hamon ac8a6d3de9 cleanup comments 2022-07-05 10:42:36 +01:00
Dominic Hamon 8205547ceb
fix sanitizer builds by using clang 13 (#1426)
* attempt to fix sanitizer builds by moving away from llvm head

* extra verbosity

* try clang 13 and add extra logging

* get latest clang and try again
2022-07-05 10:41:38 +01:00
Dominic Hamon 0a95a422b9 fix dependabot numpy version warning 2022-07-04 12:35:55 +01:00
Dominic Hamon a8bc318b9b fix cmake warning for libcxx setup 2022-07-04 12:15:49 +01:00
Yuri Khan 4136c4a3c5
Expose default help printer function (#1425)
* Pass the default help string into custom help printer

Improves #1329.

* Expose default help printer
2022-07-04 10:29:03 +01:00
Alexander Popov dfdda57a12
Fix DoNotOptimize() GCC compile error with some types (#1340) (#1424)
Non-const DoNotOptimize() can't compile when used with some types.
Example of code which can't compile:

char buffer3[3] = "";
benchmark::DoNotOptimize(buffer3);

Error message:

error: impossible constraint in 'asm'
  asm volatile("" : "+r"(value) : : "memory");

Introduced in 8545dfb (Fix DoNotOptimize() GCC copy overhead (#1340) (#1410))

The cause is compiler can't work with the +r constraint for types that can't
be placed perfectly in registers. For example, char array[3] can't be perfectly
fit in register on x86_64 so it requires placed in memory but constraint
doesn't allow that.

Solution
- Use +m,r constraint for the small objects so the compiler can decide to use
  register or/and memory
- For the big objects +m constraint is used which allows avoiding extra copy
  bug(see #1340)
- The same approach is used for the const version of DoNotOptimize()
  although the const version works fine with the "r" constraint only.
  Using mixed r,m constraint looks more general solution.

See
- Issue #1340 ([BUG] DoNotOptimize() adds overhead with extra copy of argument(gcc))
- Pull request #1410 (Fix DoNotOptimize() GCC copy overhead (#1340) #1410)
- Commit 8545dfb (Fix DoNotOptimize() GCC copy overhead (#1340) (#1410))
2022-07-04 10:27:05 +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
Dominic Hamon af7de865eb
Clarify that the cpu frequency is not used for benchmark timings. (#1414)
* Clarify that the cpu frequency is not used for benchmark timings.

Fixes #1310

* fix format (clang-format missed this...)

* oops
2022-06-20 11:22:57 +01:00
Alexander Popov 8545dfb3ea
Fix DoNotOptimize() GCC copy overhead (#1340) (#1410)
* Fix DoNotOptimize() GCC copy overhead (#1340)

The issue is that GCC DoNotOptimize() does a full copy of an argument
if it's not a pointer and it slows down a benchmark. If an argument is big
enough there is a memcpy() call for copying the argument. An argument
object can be a big object so DoNotOptimize() could add sufficient
overhead and affects benchmark results.

The cause is in GCC behavior with asm volatile constraints. Looks like GCC
trying to use r(register) constraint for all cases despite object size.
See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105519

The solution is the split DoNotOptimize() in two cases - value fits
in register and value doesn't fit in register. And use case specific
asm constraint. std::is_trivially_copyable trait is needed because
"+r" constraint doesn't work with non trivial copyable objects.

- Fix requires support C++11 feature std::is_trivially_copyable from GCC
  compiler. The feature has been supported since GCC 5
- Fallback for GCC version < 5 still exists but it uses "m" constraint
  which means a little bit more overhead in some cases
- Add assembly tests for issued cases

Fixes #1340

* Add supported compiler versions info for assembly tests

- Assembly tests are inherently non-portable. So explicitly add GCC
  and Clang versions required for reliable tests passed
- Write a warning message if the current compiler version isn't supported
2022-06-20 10:12:58 +01:00
Matthias Donaubauer efadf67a12
Add possibility to ask for libbenchmark version number (#1004) (#1403)
* Add possibility to ask for libbenchmark version number (#1004)

Add a header which holds the current major, minor, and
patch number of the library. The header is auto generated
by CMake.

* Do not generate unused functions (#1004)

* Add support for version number in bazel (#1004)

* Fix clang format #1004

* Fix more clang format problems (#1004)

* Use git version feature of cmake to determine current lib version

* Rename version_config header to version

* Bake git version into bazel build

* Use same input config header as in cmake for version.h

* Adapt the releasing.md to include versioning in bazel
2022-06-20 09:45:50 +01:00
Dominic Hamon 2365c4a603
add multiple OSes to bazel workflow (#1412)
* add multiple OSes to bazel workflow

* correct indent

* only set copts when they're supported by the OS

* os check should work

* pull out cxx03_test for per-platform stuff

* attempt to fix windows test output
2022-06-13 17:45:20 +01:00
Dominic Hamon 920fa14898 fix some build warnings on type conversions 2022-06-08 10:32:20 +01:00
Dominic Hamon 108ca84820 fix typo in comment 2022-06-07 14:15:03 +01:00
Matthdonau 6d50251d8e
Report large numbers in scientific notation in console reporter (#1303) (#1402)
Report all time numbers > 10 digits in scientific notation with
4 decimal places. This is necessary since only 10 digits
are currently reserved for the time columns (Time and CPU).
If exceeding 10 digits the output isnt properly aligned anymore.
2022-05-27 09:29:53 +01:00
Matthdonau 7eb8c0fe45
Introduce warmup phase to BenchmarkRunner (#1130) (#1399)
* Introduce warmup phase to BenchmarkRunner (#1130)

In order to account for caching effects in user
benchmarks introduce a new command line option
"--benchmark_min_warmup_time"
which allows to specify an amount of time for
which the benchmark should be run before results
are meaningful.

* Adapt review suggestions regarding introduction of warmup phase (#1130)

* Fix BM_CHECK call in MinWarmUpTime (#1130)

* Fix comment on requirements of MinWarmUpTime (#1130)

* Add basic description of warmup phase mechanism to user guide (#1130)
2022-05-23 13:50:17 +01:00
Zi Xuan Wu (Zeson) 6c46c9f593
Add support to get clock for new architecture CSKY (#1400)
it's like what loongarch does to get cycle clock for CSKY by gettimeofday function.
2022-05-23 11:47:58 +01:00