Commit graph

1255 commits

Author SHA1 Message Date
Kai Germaschewski d882be1ea9
fix cmake issue with referencing a non-existing function argument (#1118)
according to https://cmake.org/cmake/help/latest/command/function.html,
"Referencing to ARGV# arguments beyond ARGC have undefined behavior.",
which I hit with cmake 3.19.7.

This uses ARGC to check whether ARGV1 has been passed before referencing
it.
2021-04-26 09:15:07 +01:00
Roman Lebedev 058fb588b6
[tools] Fix dumb mistake in previous commit - print aggregates only means aggregates, not non-aggregates 2021-04-24 13:43:22 +03:00
Roman Lebedev 362c2ab9c6
[tools] Don't forget to print UTest when printing aggregates only
This probably regressed in #1042.
2021-04-24 13:37:13 +03:00
Roman Lebedev c05843a9f6
[sysinfo] Fix CPU Frequency reading on AMD Ryzen CPU's (#1117)
Currently, i get:
```
Run on (32 X 7326.56 MHz CPU s)
CPU Caches:
  L1 Data 32 KiB (x16)
  L1 Instruction 32 KiB (x16)
  L2 Unified 512 KiB (x16)
  L3 Unified 32768 KiB (x2)
```
which seems mostly right, except that the frequency is rather bogus.
Yes, i guess the CPU could theoretically achieve that,
but i have 3.6GHz configured, and scaling disabled.
So we clearly read the wrong thing.

With this fix, i now get the expected
```
Run on (32 X 3598.53 MHz CPU s)
CPU Caches:
  L1 Data 32 KiB (x16)
  L1 Instruction 32 KiB (x16)
  L2 Unified 512 KiB (x16)
  L3 Unified 32768 KiB (x2)
```
2021-04-23 14:33:22 +03:00
Matt Armstrong 69054ae50e
Use fewer ramp up repetitions when KeepRunningBatch is used (#1113)
Use the benchmark's reported iteration count when estimating
iterations for the next repetition, rather than the requested
iteration count.  When the benchmark uses KeepRunningBatch the actual
iteration count can be larger than the one the runner requested.

Prior to this fix the runner was underestimating the next iteration
count, sometimes significantly so.  Consider the case of a benchmark
using a batch size of 1024.  Prior to this change, the benchmark
runner would attempt iteration counts 1, 10, 100 and 1000, yet the
benchmark itself would do the same amount of work each time: a single
batch of 1024 iterations.  The discrepancy could also contribute to
estimation errors once the benchmark time reached 10% of the target.
For example, if the very first batch of 1024 iterations reached 10% of
benchmark_min_min time, the runner would attempt to scale that to 100%
from a basis of one iteration rather than 1024.

This bug was particularly noticeable in benchmarks with large batch
sizes, especially when the benchmark also had slow set up or tear down
phases.

With this fix in place it is possible to use KeepRunningBatch to
achieve a kind of "minimum iteration count" feature by using a larger
fixed batch size.  For example, a benchmark may build a map of 500K
elements and test a "find" operation.  There is no point in running
"find" just 1, 10, 100, etc., times.  The benchmark can now pick a
batch size of something like 10K, and the runner will arrive at the
final max iteration count with in noticeably fewer repetitions.
2021-04-20 07:16:05 +01:00
Dominic Hamon 0882a74c8b
Add bazel status to README 2021-04-19 17:25:59 +01:00
Dominic Hamon 2dad9aef78
Re-enable bazel without bazelisk and with scoped build/test targets (#1109)
* See if bazel "just works" now (almost)

* Add cache and better bazel test command line

* Narrow focus of bazel build
2021-04-19 10:51:12 +01:00
Dominic Hamon 39b5a298a7
Improve BENCHMARK_UNUSED definition (#1111)
Take advantage of C++17's `[[maybe_unused]]` if it's available. Also clang supports `__attribute__((unused))` so add that too.
2021-04-12 12:46:05 +01:00
Chris Lalancette 07578d82e0
Shrink the tz_offset size to 41. (#1110)
When building with gcc TSan on, and in Debug mode, we see a warning
like:

benchmark/src/timers.cc: In function ‘std::string benchmark::LocalDateTimeString()’:
src/timers.cc:241:15: warning: ‘char* strncat(char*, const char*, size_t)’ output may be truncated copying 108 bytes from a string of length 127 [-Wstringop-truncation]
  241 |   std::strncat(storage, tz_offset, sizeof(storage) - timestamp_len - 1);
      |   ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

While this is essentially a false positive (we never expect
the number of bytes in tz_offset to be too large), the compiler can't
actually tell that.  Shrink the size of tz_offset to a smaller, but still safe
size to eliminate this warning.

Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>
2021-04-09 17:32:00 +01:00
Dominic Hamon f1deaf16b8
fix minor typo (though this is an external property) 2021-04-09 13:00:43 +01:00
Dominic Hamon 5a77a6d8dc
fix minor typo 2021-04-09 13:00:06 +01:00
Dominic Hamon b8084e5054
fix minor typo 2021-04-09 12:59:31 +01:00
Tobias Schmidt 5e387e7d33
Implement custom benchmark name (#1107)
* Implement custom benchmark name

The benchmark's name can be changed using the Name() function
which internally uses SetName().

* Update AUTHORS and CONTRIBUTORS

* Describe new feature in README

* Move new name function up

Fixes #1106
2021-03-30 16:43:03 +03:00
Andre Meyering cc9abfc8f1
Fix URL to googletest primer (#1102) 2021-03-08 12:23:24 +03:00
Dominic Hamon 50c9eb5496
Removing conanfile (and support) per #1088 (#1099)
* Removing conanfile (and support) per #1088
2021-03-05 16:37:55 +00:00
Dominic Hamon 4c26070de0
disable bazel for now (#1101)
Unclear why this is failing so disabling for now. bazel build still works locally so this is a bazelisk/github workflow thing.
2021-03-05 15:04:18 +00:00
Phoenix Meadowlark 5c43112eb3
Update 'Output Files' section to reflect csv support. (#1095) 2021-02-22 09:55:59 +00:00
Phoenix Meadowlark a9b9471c02
Fix typo in invalid file name error message. (#1094) 2021-02-22 09:55:07 +00:00
SSE4 d90321ff7a
- add support for Elbrus 2000 (e2k) (#1091)
Signed-off-by: SSE4 <tomskside@gmail.com>
2021-02-14 17:45:57 +03:00
Michał Janiszewski ea5a5bbff4
Add MSVC ARM64 support for reading clocks (#1052)
Lacks CMake support, see https://github.com/google/benchmark/pull/1090
2021-02-12 13:30:26 +03:00
Yannic 8df87f6c87
Revert "Add bazel target for benchmark_release (#1078)" (#1081)
This reverts commit d8254bb9eb.
2021-01-05 09:54:04 +00:00
Dominic Hamon a6d08aea4b
Create workflow to exercise bazel build (#1079)
* Create workflow to exercise bazel build
2020-12-22 11:47:52 +00:00
Aidan Wolter d8254bb9eb
Add bazel target for benchmark_release (#1078)
Fixes google#1077

Bazel clients currently cannot build the benchmark library in Release
mode. This commit adds a new target ":benchmark_release" to enable this.
2020-12-22 09:54:33 +00:00
feserr 378ed8ff25
Add 'seconds' time unit (#1076)
Fixes #1075.

* Add an option to report in seconds.

* Reduce the time of the test.

* Add CSV/JSON tests for new time reports.
2020-12-21 20:15:58 +03:00
Dominic Hamon bf585a2789 Fix some bazel warnings about missing sha256 on http_archives 2020-11-26 11:14:03 +00:00
Scott K Logan 17a6b21ee1
Fix Range when starting at zero (#1073)
The existing behavior results in the `0` value being added twice. Since
`lo` is always added to `dst`, we never want to explicitly add `0` if
`lo` is equal to `0`.
2020-11-26 11:12:45 +00:00
Dominic Hamon 7fa6f1f91a
Disable lto-type-mismatch warnings (#1071) 2020-11-23 10:02:33 +00:00
Mario Emmenlauer 37ced31bfc
Added support for macro expansion in benchmark names (#1054)
* Adding test for defined names in test fixtures

* include/benchmark/benchmark.h: Added support for macro expansion in benchmark names
2020-11-19 13:50:30 +00:00
Alexander 348aa2c964
bazel support for tools (#982)
* packages versions updated to be in sync with modern python versions
2020-11-06 09:10:04 +00:00
Steven Wan d9abf01763
Rename 'mftbl' to 'mftb' (#1069)
* Rename 'mftbl' to 'mftb'

* Add my name to the contributor list
2020-11-03 09:08:46 +00:00
Abhina Sree a9704c268d
Nanosleep workaround for z/OS in sleep.cc (#1067)
* z/OS does not support nanosleep, add workaround to use sleep() and usleep() instead

* change unsigned to int, and fix while loop
2020-10-29 08:49:02 +00:00
Fanbo Meng dce3322a54
Add support for z/OS XL compiler inline asm syntax (#1063)
On s390 architecture, z/OS XL compiler uses HLASM inline assembly, which has different syntax and needs to be distinguished to avoid compilation error.
2020-10-21 16:39:54 +01:00
Sergei Trofimovich 3d1c267768
src/benchmark_register.h: add missing <limits> inclusion (#1060)
Noticed missing header when was building llvm with gcc-11:

```
llvm-project/llvm/utils/benchmark/src/benchmark_register.h:17:30:
  error: 'numeric_limits' is not a member of 'std'
   17 |   static const T kmax = std::numeric_limits<T>::max();
      |                              ^~~~~~~~~~~~~~
```
2020-10-15 11:12:40 +03:00
Michael Neumann af72911f2f
Add support for DragonFly BSD (#1058)
Without this commit, compilation fails on DragonFly with the following message:

```
/home/mneumann/Dev/benchmark.old/src/sysinfo.cc:446:2: error: #warning "HOST_NAME_MAX not defined. using 64" [-Werror=cpp]
^~~~~~~
```

Also note that the sysctl is actually `hw.tsc_frequency` on DragonFly:

```
$ sysctl hw.tsc_frequency
hw.tsc_frequency: 3498984022
```

Tested on:

```
$ uname -a
DragonFly box.localnet 5.9-DEVELOPMENT DragonFly v5.9.0.742.g4b29dd-DEVELOPMENT #5: Tue Aug 18 00:21:31 CEST 2020
```
2020-10-12 23:41:49 +03:00
Min-Yih Hsu ffe1342eb2
Add CycleTimer implementation for M68K architecture (#1050)
As per discussions in here [1], LLVM is going to get backend support on
Motorola 68000 series CPUs (a.k.a M68K or M680x0). So it's necessary to
add CycleTimer implementation here, which is simply using `gettimeofday`
same as MIPS. This fixes #1049

[1] https://reviews.llvm.org/D88389
2020-09-29 09:35:18 +03:00
Dominic Hamon 2d9bfe1ef8
Include github workflows status in README 2020-09-28 10:54:55 +01:00
Jusufadis Bakamovic 949f5bb11f
Add support for JSON dumps of benchmark diff reports. (#1042). Fixes #737.
NOTE: This is a fresh-start of #738  pull-request which I messed up by re-editing the commiter email which I forgot to modify before pushing. Sorry for the inconvenience.

This PR brings proposed solution for functionality described in #737 

Fixes #737.
2020-09-21 13:25:28 +03:00
Vitaly Zaitsev 7efada2dac
Fixed pkg-config on other than Ubuntu GNU/Linux distributions. (#1043)
Signed-off-by: Vitaly Zaitsev <vitaly@easycoding.org>
2020-09-12 18:56:43 +03:00
Antoine Prouvost 73d4d5e8d6
Bind benchmark builder to Python (#1040)
* Fix setup.py and reformat

* Bind benchmark

* Add benchmark option to Python

* Add Python examples for range, complexity, and thread

* Remove invalid multithreading in Python

* Bump Python bindings version to 0.2.0

Co-authored-by: Dominic Hamon <dominichamon@users.noreply.github.com>
2020-09-11 10:55:18 +01:00
Dominic Hamon df9e2948fa
Add workflow to exercise bindings (#1041)
* Initial version to try to run python bindings example

* python indent issue in setup.py

* better naming
2020-09-10 16:32:25 +01:00
Antoine Prouvost 12e85b2eeb
Bind more State methods/attributes to Python (#1037)
* Bind Counter to Python

* Bind State methods to Python

* Bind state.counters to Python

* Import _benchmark.Counter

* Add Python example of state usage

Co-authored-by: Dominic Hamon <dominichamon@users.noreply.github.com>
2020-09-10 09:57:30 +01:00
Dominic Hamon beb360d03e
Create pylint.yml (#1039)
* Create pylint.yml

* improve file matching

* fix some pylint issues

* run on PR and push (force on master only)

* more pylint fixes

* suppress noisy exit code and filter to fatals

* add conan as a dep so the module is importable

* fix lint error on unreachable branch
2020-09-09 09:43:26 +01:00
Yesudeep Mangalapilly 4751550871
Revert previous linker additions for FreeBSD as the problem is Bazel using /usr/bin/clang instead of /usr/bin/clang++ to link C++ code. (#1035) 2020-09-03 10:59:15 +01:00
Yesudeep Mangalapilly 4475ff6b8a
Adds -lm linker flag for FreeBSD/OpenBSD and uses github.com/bazelbuil… (#1032)
* Adds -lm linker flag for (Free|Open)BSD and uses github.com/bazelbuild/platforms for platform detection.

* Prefer selects.with_or to select the linkopts.

* @platforms appears to be implicitly available. @bazel_skylib would require updating every dependent repository.

* Re-enable platforms package.
2020-08-28 08:46:12 +01:00
Jeremy Ong 01c0ab7cbb
Fix Clang builds on Windows (#1021)
Fixes #974. The `cxx_feature_check` now has an additional
optional argument which can be used to supply extra cmake flags
to pass to the `try_compile` command. The `CMAKE_CXX_STANDARD=14`
flag was determined to be the minimum flag necessary to correctly
compile and run the regex feature checks when compiling with Clang
under Windows (n.b. this does *not* refer to clang-cl, the frontend
to the MSVC compiler). The additional flag is not enabled for any
other compiler/platform tuple.
2020-08-27 11:17:19 +01:00
Christian Wassermann 4857962394
Add CartesianProduct with associated test (#1029)
* Add CartesianProduct with associated test

* Use CartesianProduct in Ranges to avoid code duplication
* Add new cartesian_product_test to CMakeLists.txt
* Update AUTHORS & CONTRIBUTORS

* Rename CartesianProduct to ArgsProduct

* Rename test & fixture accordingly
* Add example for ArgsProduct to README
2020-08-25 13:47:44 +01:00
Dominic Hamon 5c25ad3acb
Ctest support (#1025)
* ctest is now working

* Update README

* remove commented out lines

* Tweaked docs

Added note to use parallel and cleaned build config notes

* Response to comments

* revert all but the readme

* make error message clearer

* drop --parallel
2020-08-21 16:25:56 +01:00
Adam Badura bb978c06d0
Update build instructions to better use CMake (#1017)
Build instructions needlessly referred to make when CMake offers
a command-line interface to abstract away from the specific build
system.

Furthermore, CMake offers command-line "tool mode" which performs basic
filesystem operations. While the syntax is a bit more verbose than
Linux commands it is platform-independent. Now the commands can be
copy-pasted on both Linux and Windows and will just work.

Finally, the Release build type is included in initial commands. A natural flow
for a new-comer is to read and execute the commands and only then learn
that one has to go back and redo them again this time with proper parameters.
Now instead the parameters are only explained later but present already in the
initial commands.
2020-08-19 11:57:19 +01:00
Dominic Hamon 5b72b6c2da
Remove "BENCHMARK_" prefix from env var version of command line flags (#997)
As noted in #995, this causes issues when the command line flag already
starts with "benchmark_", which they all do.

Not caught by tests as the test flags didn't start with "benchmark".

Fixes #995
2020-08-18 10:02:20 +01:00
Dominic Hamon 4986d0b2ea
Create build-and-test.yml (#1013)
First attempt at a non-travis/non appveyor CI solution
2020-08-18 08:53:21 +01:00