Commit Graph

1110 Commits

Author SHA1 Message Date
Dominic Hamon c5b2fe9357
Load http_archive for bazel build 2019-04-09 13:02:45 +01:00
Bryan Lunt 7a1c370283 Add process_time for better OpenMP and user-managed thread timing
* Google Benchmark now works with OpenMP and other user-managed threading.
2019-04-09 13:01:33 +01:00
Roman Lebedev 30bd6ea7f8
Fix .clang-format 2019-04-08 12:38:11 +03:00
Joseph Loser 3bc802e47c Silence CMake Policy 0063 warning (#790)
Summary:
- When google benchmark is used as a submodule in a parent projects
  whose min CMake version is 3.3.2 or later, the google benchmark
  `CMakeLists.txt` triggers a warning regarding CMake policy 0063:

```
CMake Warning (dev) at tests/googlebenchmark/src/CMakeLists.txt:19 (add_library):
  Policy CMP0063 is not set: Honor visibility properties for all target
  types.  Run "cmake --help-policy CMP0063" for policy details.  Use the
  cmake_policy command to set the policy and suppress this warning.

  Target "benchmark" of type "STATIC_LIBRARY" has the following visibility
  properties set for CXX:

    CXX_VISIBILITY_PRESET
    VISIBILITY_INLINES_HIDDEN

  For compatibility CMake is not honoring them for this target.
This warning is for project developers.  Use -Wno-dev to suppress it.
```

- Set CMake Policy 0063 to NEW if the policy is available. This will not
  affect parent projects who include benchmark but do not have a CMake min
  version of 3.3.2 or later, i.e. when this policy is introduced.
2019-04-05 11:43:47 +01:00
Dominic Hamon 6a5c379caf Set theme jekyll-theme-midnight 2019-03-28 10:53:47 +00:00
Dominic Hamon 64dcec387a Set theme jekyll-theme-midnight 2019-03-28 10:49:40 +00:00
Daniel Harvey e3666568a9 Negative ranges #762 (#787)
* Add FIXME in multiple_ranges_test.cc

* Improve handling of large bounds in AddRange.

Due to breaking the loop too early, AddRange
would miss a final multplier of 'mult' that
was within the numeric range of T.

* Enable negative values for Range argument

Fixes #762.

* Try to fix build of benchmark_gtest

* Try some more to fix build

* Attempt to fix format macros

* Attempt to resolve format errors for mingw32

* Review feedback

Put unit tests in benchmark::internal namespace

Fix error reporting in multiple_ranges_test.cc
2019-03-26 10:50:53 +00:00
BaaMeow 478eafa36b [JSON] add threads and repetitions to the json output (#748)
* [JSON] add threads and repetitions to the json output, for better ide…
[Tests] explicitly check for thread == 1
[Tests] specifically mark all repetition checks
[JSON] add repetition_index reporting, but only for non-aggregates (i…

* [Formatting] Be very, very explicit about pointer alignment so clang-format can not put pointers/references on the wrong side of arguments.
[Benchmark::Run] Make sure to use explanatory sentinel variable rather than a magic number.

* Do not pass redundant information
2019-03-26 09:53:07 +00:00
Michael Tesch fae8726690 Replace JSON inf and nan with JS compliant Infinity and NaN 2019-03-19 10:12:54 +00:00
Roman Lebedev 5acb0f05ed
Travis-ci: fix clang+libc++ build (#783)
It broke because the libc++ is being built as part of *this*
build, with old gcc+libstdc++ (4.8?), but LLVM is preparing
to switch to C++14, and gcc+libstdc++ <5 are soft-deprecated.

Just the gcc update doesn't cut it, clang still uses old libstdc++.
2019-03-17 18:48:35 +03:00
Daniel Harvey f6e96861a3 BENCHMARK_CAPTURE() and Complexity() - naming problem (#761)
Created BenchmarkName class which holds the full benchmark
name and allows specifying and retrieving different components
of the name (e.g. ARGS, THREADS etc.)

Fixes #730.
2019-03-17 16:38:51 +03:00
Roman Lebedev df7c7ee1d3
[Tooling] report.py: whoops, don't ignore the rest of benches after a bad one.
Refs #779.
2019-03-06 18:13:22 +03:00
Roman Lebedev f62c63b14f
[Tooling] report.py: don't crash on BigO/RMS benchmarks
Run into this by accident while writing benchmark to validate
the fix for https://bugs.llvm.org/show_bug.cgi?id=40965

Fixes #779.
2019-03-06 17:38:22 +03:00
Jilin Zhou d205ead299 [#774] implement GetNumCPUs(), GetCPUCyclesPerSecond(), and GetCacheSizes() (#775)
- On qnx platform, cpu and cache info is stored in a syspage struct which
  is different from other OS platform.
- The fix has been verified on an aarch64 target running qnx 7.0.
Fixes #774
2019-02-28 10:42:44 +00:00
Jilin Zhou 0ae233ab23 [#766] add x-compile support for QNX SDP7 (#770)
Since googletest already supports x-compilation for QNX, it is nice to
 have google benchmark support it too.
Fixes #766
2019-02-19 13:05:55 +00:00
Wes McKinney 7c571338b5 Prefer -pthread to -lpthread for better compatibility when cross-compiling (#771) 2019-02-19 12:32:11 +00:00
Roman Lebedev b8ca0c4217
README.md: mention that fixture has SetUp() / TearDown() 2019-02-04 16:26:51 +03:00
Daniel Kraft 97393e5ef8 Add -lpthread to pkg-config Libs.private. (#755)
Since pthread is required at least for GCC (according to the
documentation), this should be reflected by the pkg-config file.

The same is, for instance, also done by the gflags library:
1005485222/cmake/package.pc.in (L13)
2019-02-01 15:51:44 +03:00
Dominic Hamon 785e2c3158
Move Statistics struct to internal namespace (#753) 2019-01-15 13:19:36 +00:00
Andriy Berestovskyy 4b9f43e2c4 Fix header lines length (#752)
Commit 17a012d7 added a newline to the str, so the line built from
str.length() is one character longer than it should be.
2019-01-13 17:26:49 +03:00
Michael "Croydon" Keck eec9a8e497 Add minimal Conan support (#728) 2019-01-03 13:42:07 +00:00
Reid Kleckner dc10645549 Set CMP0048 policy before project() to silence warnings (#750)
If this policy isn't set, CMake emits a large warning when project() is
called from a cmake subdirectory.

This came up when the benchmark library was added to the LLVM build, and
it was reported in https://llvm.org/PR38874. This patch was the fix I
applied locally to fix the issue, and I wanted to send it upstream.
2018-12-30 20:46:07 +03:00
Eric 4528c76b71
Print at least three significant digits for times. (#701)
Some benchmarks are particularly sensitive and they run in less than
a nanosecond. In order for the console reporter to provide meaningful
output for such benchmarks it needs to be able to display the times
using more resolution than a single nanosecond.

This patch changes the console reporter to print at least three
significant digits for all results.

Unlike the initial attempt, this patch does not align the decimal point.
2018-12-13 22:49:21 -05:00
Roman Lebedev 57bf879d49
README.md: document State::{Pause,Resume}Timing()
As pointed out in IRC, these are not documented.
2018-12-14 01:20:01 +03:00
Dominic Hamon 0ed529a7e3
Update documentation of benchmark_filter (#744)
It should now match reality.
2018-12-13 11:14:50 +00:00
Jatin Chaudhary 47a5f77d75 #722 Adding Host Name in Reporting (#733)
* Adding Host Name and test

* Addressing Review Comments

* Adding Test for JSON Reporter

* Adding HOST_NAME_MAX for MacOS systems

* Adding Explaination for MacOS HOST_NAME_MAX Addition

* Addressing Peer Review Comments

* Adding codecvt in windows header guard

* Changing name SystemInfo and adding empty message incase host name fetch fails

* Adding Comment on Struct SystemInfo
2018-12-11 11:23:02 +00:00
Tobias Ulvgård 1f3cba06e4 Update reference to complexity calculation (#723) 2018-12-10 15:15:34 +00:00
Cyrille 5cb8f8a03d Fix signed vs unsigned comparisons in string_util unit tests (#742)
Unit-tests fail to build due to the following errors:

/home/cfx/Dev/google-benchmark/benchmark.git/test/string_util_gtest.cc:12:5: required from here
/home/cfx/Applications/googletest-1.8.1/include/gtest/gtest.h:1444:11: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
   if (lhs == rhs) {
       ~~~~^~~~~~

Fixes #741
2018-12-10 10:24:22 +00:00
Jusufadis Bakamovic eee8b05c97 [tools] Run autopep8 and apply fixes found. (#739) 2018-12-07 16:34:00 +03:00
Eric eafa34a5e8
Remove use of std::tmpnam. (#734)
std::tmpnam is deprecated and its use is discouraged. For our purposes
in the tests, we really just need a file name which is unlikely to
exist.

This patch converts the tests to using a dummy random file name
generator, which should hopefully avoid name conflicts.
2018-11-29 22:51:44 -05:00
Roman Lebedev 19f7d5c2bc
README.md: complexity lambda takes int64_t arg. Fixes #719 2018-11-29 01:23:25 +03:00
Roman Lebedev c9f2693ea9 StrFormat() is a printf-like function, mark it as such, fix fallout. (#727)
Fixes #714.
2018-11-26 19:55:05 -05:00
Roman Lebedev c9311a44e1
README.md: BM_Sequential(): the return type is 'void'
Used that example as a snippet, and it took a moment to notice
what needed to be changed to make it compile..
2018-11-26 15:39:36 +03:00
Denis Glazachev 56f5cd6a72 Fix C++17 mode compilation with Apple clang (#721) 2018-11-21 21:38:24 -05:00
Dominic Hamon b1717916d1 Merge branch 'atdt-report_loadavg' 2018-11-13 10:14:28 +00:00
Dominic Hamon b5082bbd65 Merge branch 'report_loadavg' of https://github.com/atdt/benchmark into atdt-report_loadavg 2018-11-13 10:13:58 +00:00
Dominic Hamon bb15a4e3bf Ensure all informational cmake messages have STATUS type 2018-11-13 09:56:22 +00:00
Kirill Bobyrev a9b31c51b1 Disable exceptions in Microsoft STL (#715)
This is the copy of patch proposed to LLVM's copy of benchmark via
https://reviews.llvm.org/D52998.
2018-11-02 16:03:49 +00:00
Anton Gladky c6193afe7e Fix parsing of cpuinfo for s390 platform. (#712)
s390 has another line structure for processor-field.
It should be differently parsed.
2018-10-21 11:01:42 +03:00
Roman Lebedev 507c06e636
Aggregates: use non-aggregate count as iteration count. (#706)
It is incorrect to say that an aggregate is computed over
run's iterations, because those iterations already got averaged.
Similarly, if there are N repetitions with 1 iterations each,
an aggregate will be computed over N measurements, not 1.
Thus it is best to simply use the count of separate reports.

Fixes #586.
2018-10-18 17:17:14 +03:00
Roman Lebedev 99d1356c04
[NFC] BenchmarkRunner: always populate *_report_aggregates_only bools. (#708)
It is better to let the RunBenchmarks(), report() decide
whether to actually *only* output aggregates or not,
depending on whether there are actually aggregates.

It's subtle indeed.

Previously, `BenchmarkRunner()` always said that "if there are no repetitions,
then you should never output only the repetitions". And the `report()` simply assumed
that the `report_aggregates_only` bool it received makes sense, and simply used it.

Now, the logic is the same, but the blame has shifted.
`BenchmarkRunner()` always propagates what those benchmarks would have wanted
to happen wrt the aggregates. And the `report()` lambda has to actually consider
both the `report_aggregates_only` bool, and it's meaningfulness.

To put it in the context of the patch series - if the repetition count was `1`,
but `*_report_aggregates_only` was set to `true`, and we capture each iteration separately,
then we will compute the aggregates, but then output everything, both the iteration,
and aggregates, despite `*_report_aggregates_only` being set to `true`.
2018-10-18 15:08:59 +03:00
Roman Lebedev 9cacec8e78
[NFC] RunBenchmarks(): s/has_repetitions/might_have_aggregates/ (#707)
That is the real purpose of that bool. A follow-up change will
make it consider something else other than repetitions.
2018-10-18 15:03:17 +03:00
Olzhas Kaiyrakhmet d731697a5d Fix SOURCE_DIR in HandleGTest.cmake (#705)
If benchmark added as cmake subproject, HandleGTest throws an error as  does return absolute source dir.
Change it to , so it will be refering to it's own source dir.

Also see PR #703.
2018-10-13 01:06:41 -07:00
Eric 8356d646bf
Revert "Fix SOURCE_DIR in HandleGTest.cmake (#703)" (#704)
This reverts commit 609752306f.
2018-10-13 00:53:25 -07:00
Olzhas Kaiyrakhmet 609752306f Fix SOURCE_DIR in HandleGTest.cmake (#703)
* Fix SOURCE_DIR in HandleGTest.cmake

If benchmark added as cmake subproject, HandleGTest throws an error as  does return absolute source dir.
Change it to , so it will be refering to it's own source dir.
2018-10-13 00:51:51 -07:00
Ilya A. Kriveshko 8503dfe537 benchmark_color: fix auto option (#559) (#699)
As prevously written, "--benchmark_color=auto" was treated as true,
because IsTruthyFlagValue("auto") returned true.  The fix is to
rely on IsColorTerminal test only if the flag value is "auto",
and fall back to IsTruthyFlagValue otherwise.  I also integrated
force_no_color check into the same block.
2018-10-08 09:33:21 +01:00
Gregorio Litenstein 9ffb8df6c5 Fix Clang Detection (#697)
For several versions now, CMake by default refers to macOS’ Clang as AppleClang instead of just Clang, which would fail STREQUAL. Fixed by changing it to MATCHES.
2018-10-05 16:44:02 +01:00
Roman Lebedev a8082de5df
[NFC] Refactor RunBenchmark() (#690)
Ok, so, i'm still trying to get to the state when it will be a trivial change to report all the separate iterations.
The old code (LHS of the diff) was rather convoluted i'd say.
I have tried to refactor it a bit into *small* logical chunks, with proper comments.
As far as i can tell, i preserved the intent of the code, what it was doing before.
The road forward still isn't clear, but i'm quite sure it's not with the old code :)
2018-10-01 17:51:08 +03:00
Victor Costan d8c0f27448 Fix possible loss of data warnings in MSVC. (#694) 2018-10-01 13:00:13 +01:00
Dominic Hamon edc77a3669
Make State constructor private. (#650)
The State constructor should not be part of the public API. Adding a
utility method to BenchmarkInstance allows us to avoid leaking the
RunInThread method into the public API.
2018-09-28 12:28:43 +01:00