Commit Graph

1461 Commits

Author SHA1 Message Date
Paul Wankadia e057a7cee2
Make generate_export_header.bzl work for Windows. (#1355)
* Make generate_export_header.bzl work for Windows.

While I'm here, bring the generated code slightly closer to what CMake
would generate nowadays.

Fixes #1351.

* Fix define.

* Fix export_import_condition.

* Fix guard.
2022-02-24 14:42:59 +00:00
Dominic Hamon e82a6ed704
avoid case sensitive issues with duplicated names (#1354) 2022-02-22 13:53:29 +00:00
Dominic Hamon b46208fcf0
move bzl file out of tools (#1352) 2022-02-21 12:03:18 +00:00
Vincenzo Palazzo c563644040
Introduce the possibility to customize the help printer function (#1342)
* introduce the possibility to customize the help printer function

Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>

* fixed naming convertion, and introduce the option function in the init method

Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>

* remove the macros to inject the helper function

Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>

* remove the default implementation, and introduce the nullprt

Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2022-02-16 09:23:54 +00:00
Dominic Hamon 28b210ebb8
simplify reference to internal path (#1349) 2022-02-15 14:06:31 +00:00
Vy Nguyen 7b46d3ddbf
Check for macro existence before using (#1347) 2022-02-14 17:00:44 +00:00
Sergiu Deitsch 9e47d070fe
annotate and export public symbols (#1321) 2022-02-14 10:48:53 +00:00
Dominic Hamon 6e51dcbcc3
Expose default display reporter creation in public API (#1344)
* Expose default display reporter creation in public API

this is useful when a custom reporter wants to fall back on the default
display reporter, but doesn't necessarily have access to the benchmark
library flag configuration.

* Make use of unique_ptr in the random interleaving test.

* clang-format
2022-02-11 10:23:05 +00:00
staffantj d2cbd4b26a
Avoid potential truncation issues for the integral type parameterized tests. (#1341)
* The parameterized tests check both floating point and integral types. We might as well use types that avoid truncation warnings across the platforms

* static_cast version of how to avoid truncation warnings in basic_test

Co-authored-by: Staffan Tjernstrom <staffantj@users.noreply.github.com>
2022-02-08 16:40:43 +00:00
Liqiang TAO bdea5051b0
Add mutex when reading counters_ (Fixes #1335) (#1338) 2022-02-07 13:03:19 +00:00
batortaller 1ee7bee6c5
Use Win32 API only for Win32 apps (#1333) 2022-02-02 12:16:19 +03:00
Dominic Hamon 14eee07f4a
bump numby, as per dependabot (#1336) 2022-01-31 10:28:11 +00:00
Nicholas Junge 6d51a119ff
Fix cross compilation for macOS ARM builds in `cibuildwheel` (#1334)
This commit contains a fix for macOS ARM64 wheel buils in Google Benchmark's wheel building CI.

Previously, while `cibuildwheel` itself properly identified the need for cross-compilations and produced valid ARM platform wheels, the included shared library containing the Python bindings
built by `bazel` was built for x86, resulting in immediate errors upon import.

To fix this, logic was added to the setup.py file that adds the "--cpu=darwin_arm64" and "--macos_cpus=arm64" switches to the `bazel build` command if
1) The current system platform is macOS Darwin running on the x86_64 architecture, and
2) The ARCHFLAGS environment variable, set by wheel build systems like conda and cibuildwheel, contains the tag "arm64".

This way, bazel correctly sets the target CPU to ARM64, and produces functional wheels for the macOS ARM line of CPUs.
2022-01-26 09:13:26 +00:00
Liqiang TAO d0fbf8ac23
Cache PerfCounters instance in PerfCountersMeasurement (#1308)
This patch fixes #1306, by reducing the pinned instances of
PerfCounters.

The issue is caused by creating multiple pinned events in the
same thread, doing so results in the Snapshot(PerfCounterValues* values)
failing, and that's now discoverable.
Creating multile pinned events is an unsupported behavior currently.
The error would be detected at read() time, not
perf_event_open() / iotcl() time.

The unsupported benavior above is confirmed by Stephane Eranian @seranian,
and he also pointed the dectection method.

Finished this patch under the guidance of Mircea Trofin @mtrofin.
2022-01-25 10:14:20 +00:00
YuanYingdong 57b2bfa33b
Fix some errors in Custom Statistics demo code. (#1332) 2022-01-24 09:51:02 +00:00
Matt Armstrong acd7562034
Refine the User Guide CPU Frequency Scaling section (#1331)
* Revert "Refine docs on changing cpufreq governor (#1325)"

This reverts commit 9e859f5bf5.

* Refine the User Guide CPU Frequency Scaling section

The text now describes the cpupower command, so users in a hurry
have something to copy/paste that will likely work.  It then
suggests that there are probably more convenient optons available
that people can look into.

This reverts the prior commit, which introduced a shell script
that doesn't work.  It also retains the spirit of the original
fix: no longer recommend setting the frequency governor to
"powersave", which might not be appropriate or available.

Note: I did attempt to write a bash script that set the govenor
to "powersave" for the duration of a single command, but I gave
up for many reasons:

 1) it got complex, in part because the cpupower command does not
 seem to be designed for scripts (e.g. it prints out complex
 English phrases).

 2) munging /proc/sys files directly feels unstable and less than
 universal.  The libcpupower and cpupower are designed to abstract
 those away, because the details can vary.

 3) there are better options.  E.g. various GUI programs, and
 even Gnome's core Settings UI, let you adjust the system's
 performance mode without root access.

Fixes #1325, #1327
2022-01-21 16:24:49 +00:00
Dominic Hamon 9e859f5bf5
Refine docs on changing cpufreq governor (#1325)
Ensure we don't have users accidentally putting their CPUs into
powersave.

Fixes #1048
2022-01-17 14:52:02 +00:00
Dominic Hamon 00e2211052
Expand documentation for unpacking arbitrary arguments. (#1324)
Fixes #1123
2022-01-17 13:54:56 +00:00
Dominic Hamon 6cf20f1e02
Suppress GoogleTest warnings on windows (MSVC) too. (#1320)
Fixes #1209
2022-01-13 14:21:43 +00:00
Dominic Hamon 5531ec80f7
Add docs on Memory profiling (#1217). (#1319) 2022-01-13 10:19:22 +00:00
Dominic Hamon 31e7941796
Add docs for `ThreadRange`. (#1318)
Fixes #1297
2022-01-12 15:07:31 +00:00
Dominic Hamon 0d98dba29d Creating release commit for v1.6.1 2022-01-10 19:14:27 +00:00
staffantj 0e78738a25
Destructor not returning is expected in some cases (#1316)
* Address MSVC C4722 warning in tests

Some test paths deliberately exit, and it appears that the appropriate declspec
does not stop the compiler generating the C4722 warning as one might expect.

Per https://github.com/google/benchmark/issues/826#issuecomment-851995549
this commit ignores the warning for the affected call site.

* Fix up Formatting

* Fix up formatting issue on pragmas

* Fix up formatting issue on pragmas take 2

Co-authored-by: Staffan Tjernstrom <staffantj@users.noreply.github.com>
2022-01-10 15:44:42 +00:00
staffantj 6dfe7afbc3
Address c4267 warning on MSVC (#1315)
* Fix #1159 Harmonize the types between the loop counter and the vector of indices

The loop counter is a size_t, but they're stored in a vector-of-int leading to
potential overflow warnings. In order to avoid accidental run-time overflow
this change modifies the vector type, rather than the loop counter.

* Fix up line endings

* Update AUTHORS

Add Staffan Tjernstrom <staffantj@gmail.com>

Co-authored-by: Staffan Tjernstrom <staffantj@users.noreply.github.com>
2022-01-10 14:43:29 +00:00
Roman Lebedev 3b3de69400
Fix `-DBENCHMARK_ENABLE_INSTALL=OFF` (Fixes #1275) (#1305)
Otherwise this fails with
```
CMake Error at src/CMakeLists.txt:154 (export):
  export Export set "benchmarkTargets" not found.
```

This is what https://cmake.org/cmake/help/latest/guide/importing-exporting/index.html#exporting-targets
seems to suggest.

While there, really respect BENCHMARK_ENABLE_INSTALL,
BENCHMARK_INSTALL_DOCS shouldn't override it.
2021-12-14 09:46:23 +00:00
Martin Storsjö b000672793
Avoid errors due to "default label in switch which covers all enumeration values" in Windows codepath (#1302)
This applies a fix that used to exist in LLVM's downstream copy of
this library, from
948ce4e6ed.

I presume this warning isn't present if built with MSVC or Clang-cl,
but it's printed in MinGW mode. As the benchmark library adds
-Werror, this is a fatal error when builtin MinGW mode.
2021-12-09 09:24:54 +00:00
Dominic Hamon 1f99405076
update googletest to latest release tag 1.11.0 (#1301)
* update googletest to latest release tag 1.11.0

* fix cmake builds to the same release
2021-12-08 16:30:03 +00:00
dominc8 ab867074da
clang-tidy: readability-redundant and performance (#1298)
* clang-tidy: readability-redundant-*

* clang-tidy: performance-*
2021-12-06 11:18:04 +00:00
Shawn Zhong fd258bbd13
Update user_guide.md (#1296) 2021-12-02 09:40:35 +00:00
Robert Adam fe2e8aa1b4
Fix broken link to Setup/Teardown section (#1291) 2021-11-26 11:37:16 +00:00
dominc8 680d3fdbb5
Add clang-tidy check (#1290)
* Add clang-tidy.yml and .clang-tidy

* Add mention to authors/contributors

* Temp fix 2 clang-tidy issues

* Enable clang-tidy on pull requests

* Exclude gtest source files from clang-tidy
2021-11-25 15:47:44 +00:00
Roman Lebedev d6ba952fc1
compare.py: compute and print 'OVERALL GEOMEAN' aggregate (#1289)
Despite the wide variety of the features we provide,
some people still have the audacity to complain and demand more.

Concretely, i *very* often would like to see the overall result
of the benchmark. Is the 'new' better or worse, overall,
over all the non-aggregate time/cpu measurements.

This comes up for me most often when i want to quickly see
what effect some LLVM optimization change has on the benchmark.

The idea is straight-forward, just produce four lists:
wall times for LHS benchmark, CPU times for LHS benchmark,
wall times for RHS benchmark, CPU times for RHS benchmark;
then compute geomean for each one of those four lists,
and compute the two percentage change between
* geomean wall time for LHS benchmark and geomean wall time for RHS benchmark
* geomean CPU time for LHS benchmark and geomean CPU time for RHS benchmark
and voila!

It is complicated by the fact that it needs to graciously handle
different time units, so pandas.Timedelta dependency is introduced.
That is the only library that does not barf upon floating times,
i have tried numpy.timedelta64 (only takes integers)
and python's datetime.timedelta (does not take nanosecons),
and they won't do.

Fixes https://github.com/google/benchmark/issues/1147
2021-11-24 10:47:08 +00:00
Dominic Hamon ce92bbfb90 remove long-defunct cli parameter 2021-11-19 19:58:08 +00:00
Dominic Hamon 88ea9d9005 lose some build warnings 2021-11-19 19:54:05 +00:00
Vy Nguyen 91ed7eea68
Disable clang-tidy (unused-using-decls) (#1287)
The NOLINTBEGIN block only covers warnings on `long` types and other styling issues but not clang-tidies.
2021-11-19 11:12:59 +00:00
Vy Nguyen 8722d6f014
disable lint check where we know it'd fail (#1286)
* disable lint check where we know it'd fail

one less noisy presubmit

* clang format

* remove ws
2021-11-17 17:57:36 +00:00
Vy Nguyen b5bb9f0675
Add Setup/Teardown option on Benchmark. (#1269)
* Add Setup/Teardown option on Benchmark.

Motivations:
- feature parity with our internal library. (which has ~718 callers)
- more flexible than cordinating setup/teardown inside the benchmark routine.

* change Setup/Teardown callback type to raw function pointers

* add test file to cmake file

* move b.Teardown() up

* add const to param of Setup/Teardown callbacks

* fix  comment and add doc to user_guide

* fix typo

* fix doc, fix test and add bindings to python/benchmark.cc

* fix binding again

* remove explicit C cast - that was wrong

* change policy to reference_internal

* try removing the bindinds ...

* clean up

* add more tests with repetitions and fixtures

* more comments

* init setup/teardown callbacks to NULL

* s/nullptr/NULL

* removed unused var

* change assertion on fixture_interaction::fixture_setup

* move NULL init to .cc file
2021-11-17 16:51:55 +00:00
Donald Aingworth a07f6d1789
Googletest renamed master to main today. (#1285)
Co-authored-by: Donald Aingworth <donald@midpointmarkets.org>
2021-11-17 09:45:03 +00:00
Teodor Spæren 8401429e74
Remove bazelbuild/rules_cc dependency (#1283)
It seems according to [1] that bazelbuild/rules_cc has been put on hold
and that the recommended way for now, is to use the native cc rules.

[1]: https://github.com/bazelbuild/rules_go/pull/2950
2021-11-14 12:02:58 +00:00
Alisenai 926f61da9a
Support for building with LLVM clang-10/clang-11 on Windows. (#1227)
* Fix enum underlying type specification

* Fix C++0x-only solution
2021-11-14 11:52:27 +00:00
Nicholas Junge a17480dd34
Fix dependency typo and unpin cibuildwheel version in wheel building … (#1263)
* Fix dependency typo and unpin cibuildwheel version in wheel building action

* Move to monolithic build jobs, restrict to x64 architectures

As of this commit, all wheel building jobs complete on GitHub Actions. Since some platform-specific options had to be set to fix different types of build problems underway, the build job matrix was unrolled.

Still left TODO:
* Wheel testing after build (running the Python bindings test)
* Emulating bazel on other architectures to build aarch64/i686/ppc64le
* Enabling Win32 (this fails due to linker errors).

* Add binding test commands for all wheels, set macOSX deployment target to 10.9

* Add instructions for updating Python __version__ variable before release creation
2021-11-11 14:51:22 +00:00
Dominic Hamon b3c08f6ec3
check clang format on pull requests and merges (#1281)
* check clang format on pull requests and merges

* manage some formatting by hand

* undo one format too many
2021-11-10 16:49:49 +00:00
Dominic Hamon c07a498924
format tests with clang-format (#1282) 2021-11-10 16:22:31 +00:00
Dominic Hamon fcef4fb669
clang-format Google on {src/,include/} (#1280) 2021-11-10 16:04:32 +00:00
Bensuperpc 431abd149f
Fix warning with MacOS (#1276)
* Fix warning with MacOS

Signed-off-by: Bensuperpc <bensuperpc@gmail.com>

* Re-trigger GitHub actions

Signed-off-by: Bensuperpc <bensuperpc@gmail.com>

* Fix style

Signed-off-by: Bensuperpc <bensuperpc@gmail.com>

* Revert "Fix style"

This reverts commit 1d5fe9ce87.

* Fix style only on changes

Signed-off-by: Bensuperpc <bensuperpc@gmail.com>
2021-11-08 12:39:36 +00:00
Vy Nguyen 4b99670c57
Fixed typo in doc: s/marcro/macro (#1274)
* Fixed typo s/marcro/macro

* undo stray NL

* abc
2021-11-08 10:04:03 +00:00
Bensuperpc 329fb06d99
Fix error with Fix Werror=old-style-cast (#1272)
* Fix Werror=old-style-cast

Signed-off-by: Bensuperpc <bensuperpc@gmail.com>

* Fix Werror=old-style-cast

Signed-off-by: Bensuperpc <bensuperpc@gmail.com>

* Fix Werror=old-style-cast

Signed-off-by: Bensuperpc <bensuperpc@gmail.com>

* Fix typo

Signed-off-by: Bensuperpc <bensuperpc@gmail.com>

* Fix build error with MacOS

Signed-off-by: Bensuperpc <bensuperpc@gmail.com>

* Revert "Fix build error with MacOS"

This reverts commit cee213bb95.
2021-11-04 12:09:10 +00:00
Bensuperpc 8826ef792f
Fix error Wshorten-64-to-32 (#1273)
Signed-off-by: Bensuperpc <bensuperpc@gmail.com>
2021-11-04 10:26:11 +00:00
Vy Nguyen 8aae0a4f67
[cleanup] Change `== ""` to `.empty()` on string to avoid clang-tidy warnings (#1271) 2021-11-03 14:54:07 +00:00
Vy Nguyen 4f31803ebb
Fix un-initted error in test and fix change the API previously proposed to use std::string instead of raw char* (#1266)
* Fix un-initted error in test.

Found by -Werror,-Wsometimes-uninitialized

* Update spec_arg_test.cc

* additional change:
- Change the API on GetBenchmarkFilter and the `spec` to std::string because google C++ styleguide internally kind of discouraged  using raw const char*
2021-10-29 11:48:56 +01:00