Commit graph

574 commits

Author SHA1 Message Date
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
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
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
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
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 920fa14898 fix some build warnings on type conversions 2022-06-08 10:32:20 +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
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 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
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
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
Vy Nguyen eacce0b503
Add SetBenchmarkFilter() to set --benchmark_filter flag value in user code (#1362)
* Add SetBenchmarkFilter() to set --benchmark_filter flag value in user code.

Use case:  Provide an API to set this flag indepedence of the flag's implementation (ie., absl flag vs benchmark's flag facility)

* add test

* added notes on Initialize()
2022-03-08 16:02:37 +00:00
Bátor Tallér d08e7b6056
Allow setting the default time unit globally (#1337)
* Add option to set the default time unit globally

This commit introduces the `--benchmark_time_unit={ns|us|ms|s}` command line argument. The argument only affects benchmarks where the time unit is not set explicitly.

* Update AUTHORS and CONTRIBUTORS

* Test `SetDefaultTimeUnit`

* clang format

* Use `GetDefaultTimeUnit()` for initializing `TimeUnit` variables

* Review fixes

* Export functions

* Add comment
2022-03-04 11:07:01 +00:00
Sergiu Deitsch e33986a000
restore BENCHMARK_MAIN() (#1357) 2022-02-26 10:17:13 +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
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
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
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
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
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
dominc8 ab867074da
clang-tidy: readability-redundant and performance (#1298)
* clang-tidy: readability-redundant-*

* clang-tidy: performance-*
2021-12-06 11:18:04 +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
Dominic Hamon ce92bbfb90 remove long-defunct cli parameter 2021-11-19 19:58:08 +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
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 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
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
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
Vy Nguyen 4f47ed2c9a
[RFC] Adding API for setting/getting benchmark_filter flag? (#1254)
* [RFC] Adding API for setting/getting benchmark_filter flag?

This PR is more of a Request-for-comment - open to other ideas/suggestions as well.

Details:
This flag has different implementations(absl vs benchmark) and since the proposal to add absl as a dependency was rejected, it would be nice to have a reliable (and less hacky) way to access this flag internally.
(Actually, reading it isn't much a problem but setting it is).

Internally, we have a sizeable number users to use absl::SetFlags to set this flag. This will not work with benchmark-flags.

Another motivation is that not all users use the command line flag. Some prefer to programmatically set this value.

* fixed build errors

* fix lints again

* per discussion: add additional RunSpecifiedBenchmarks instead.

* add tests

* fix up tests

* clarify comment

* fix stray : in test

* more assertion in test

* add test file to test/CMakeLists.txt

* more test

* make test ISO C++ compliant

* fix up BUILD file to pass the flag
2021-10-27 08:52:57 +01:00
Vitaly Zaitsev 365670e432
Added Doxygen support. (#1228)
Signed-off-by: Vitaly Zaitsev <vitaly@easycoding.org>
2021-10-25 12:32:33 +01:00
Byoungchan Lee 80d70ddd94
Fix -Wdeprecated-declarations warning once more. (#1256)
In #1238, one of MemoryManager's Stop methods was marked as deprecated
and this method is used in the same header. This change generated
-Wdeprecated-declarations warning on every file that includes
"benchmark.h". Use gcc's diagnostics to fix this warning.
2021-10-21 10:10:38 +01:00
Sergiu Deitsch 1be88c0683 cmake: allow to use package config from build directory 2021-10-19 11:11:11 +02:00