Commit graph

1567 commits

Author SHA1 Message Date
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
Vy Nguyen a480a088fe
[nfc] Reformat doc-string in generate_export_header (#1376)
This was previously not compliant with Buildifier checker
2022-03-17 18:31:36 +00:00
Paul Wankadia 808571a52f
Fix Bazel build breakage caused by commit 6a894bd. (#1374) 2022-03-17 09:29:50 +00:00
Paul Wankadia 6a894bd555
Build //:benchmark as a static library only. (#1373)
If someone or something ever needs the dynamic library as a Bazel build
artifact, we can figure that out for them then, but right now, there is
no strong reason to be wrangling various `export.h`-controlling macros.

Fixes #1372.
2022-03-17 08:47:45 +00:00
Dominic Hamon 5704cd4c8c
add note about wheels action to releasing docs 2022-03-15 15:11:43 +00:00
Nicholas Junge 3eab98544f
Change artifact download name to dist to match upload name (#1371) 2022-03-15 12:56:01 +00:00
Nicholas Junge 7d6f1534e9
Remove conditional trigger from PyPI upload job (#1370) 2022-03-15 11:06:30 +00:00
Nicholas Junge 9a71e5d748
Add BENCHMARK_STATIC_DEFINE to the Python bindings' cc_binary local defines. (#1369)
This commit fixes the previous breakage in Python wheel builds for Windows by adding a `local_defines` field to the `cc_binary` generated in the process of the Python bindings builds. This define is being
picked up by the auto-generated export header `benchmark_export.h`, unsetting the benchmark export macro.
Furthermore, the `linkshared` and `linkstatic` attributes are passed booleans now instead of ints, making the command more directly interpretable to the human reader.

The fix was suggested by @junyer in the corresponding GitHub issue thread https://github.com/google/benchmark/issues/1367 - thank you for the suggestion!
2022-03-14 12:22:45 +00:00
Vy Nguyen 4a1943d611
Update LICENSE file to clearly state which file needs BSD 3 (#1366)
Follow up to PR/1363
2022-03-14 09:50:46 +00:00
Bensuperpc 4f77cf9e62
Fix float comparaison and add float comparison warning (#1368)
GCC warns about comparison with zero, clang does not.
2022-03-12 19:05:23 +03:00
Nicholas Junge 705202d22a
Add PyPI upload job to wheel building workflow (#1359)
This commit adds a job running after the wheel building job responsible for uploading the built wheels to PyPI.
The job only runs on successful completion of all build jobs, and uploads to PyPI using a secret added to the Google Benchmark repo (TBD).
Also, the setup-python action has been bumped to the latest version v3.
2022-03-10 16:56:55 +00:00