Commit Graph

1327 Commits

Author SHA1 Message Date
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
Matthdonau 37be1e8252
Add option to get the verbosity provided by commandline flag -v (#1330) (#1397)
* Add option to get the verbosity provided by commandline flag -v (#1330)

* replace assert with test failure

asserts are stripped out in non debug builds, and we run tests in non-debug CI bots.

* clang-format my own tweak

Co-authored-by: Dominic Hamon <dominichamon@users.noreply.github.com>
2022-05-17 17:59:36 +01:00
cui fliter aecbdbff4f
fix some typos (#1393)
Signed-off-by: cuishuang <imcusg@gmail.com>
2022-05-11 09:03:20 +01:00
Nicholas Junge bc4639c154
Add installation and build instructions for Python bindings (#1392)
This commit adds a small section on how to install and build Python
bindings wheels to the docs, as well as a link to it from the main readme.

Notes were added that clearly state availability of Python wheels based
on Python version and OS/architecture combinations.

For the guide to build a wheel from source, the best practice of
creating a virtual environment and activating it before build was
detailed. Also, a note on the required installation of Bazel was added,
with a link to the official docs on installation.
2022-05-10 13:16:00 +01:00
Dominic Hamon 8d86026c67
Enable -Wconversion (#1390)
Requires some casts here and there, but nothing unreasonable.

Fixes #1268
2022-05-01 19:56:30 +01:00
Dominic Hamon b0d5adfacd
Add benchmark labels to the output of the comparison tool (#1388)
Fixes #1294
2022-05-01 15:04:39 +01:00
Dominic Hamon a162a38ca0
Filter out benchmarks that start with "DISABLED_" (#1387)
* Filter out benchmarks that start with "DISABLED_"

This could be slightly more elegant, in that the registration and the
benchmark definition names have to change.  Ideally, we'd still register
without the DISABLED_ prefix and it would all "just work".

Fixes #1365

* add some documentation
2022-05-01 10:41:34 +01:00
Nicholas Junge dc901ff909
Fix wheel job name for PyPI uploads (#1384)
Previously, with the unrolled job matrix, all jobs had to be listed individually in the `needs` section of the PyPI upload job. But as the wheel build job was reimplemented as a job matrix now, with a
single build job name `build_wheels`, we need to adjust the name in the PyPI upload job as well here to avoid errors.
2022-04-11 09:17:54 +01:00
Nicholas Junge 6f75bb5273
Shut down Bazel gracefully and revert wheel build strategy to job matrix (#1383)
This commit adds a `bazel shutdown` command to the setuptools BazelExtension. This has the effect that wheel builds shut down the Bazel server and terminate gracefully after the build, something
that was previously an issue on Windows builds.

Since the windows-specific `--no-clean` flag option to `pip wheel` becomes unnecessary due to this change, this change has the side-effect that GitHub Actions wheel builds via `cibuildwheel` can now
be written as a compact job matrix again, which leads to a lot of deduplicated code in the corresponding workflow file.

Lastly, some GitHub-provided actions (checkout, setup-python, upload/download-artifact) were bumped to the latest v3 version.
2022-04-08 15:00:46 +01:00
Dominic Hamon 74ae567294
Small optimization to counter map management (#1382)
* Small optimization to counter map management

Avoids an unnecessary lookup.

* formatting
2022-04-07 14:37:22 +01:00
Dominic Hamon 3eac3b60d2
getting sysinfo in line with Google style (#1381)
* getting sysinfo in line with Google style

* format tweak

* fixing osx compile errors

* more style tweaks
2022-04-07 10:50:52 +01:00
Brad Messer 60b16f11a3
Promote inclusive language. (#1360) 2022-03-18 15:59:31 +00:00