Commit graph

1097 commits

Author SHA1 Message Date
Colin Braley e7e3d976ef Add missing parenthesis to code sample, and fix spacing. (#877)
* Fix missing paren in README code sample, and fix code spacing.

* Add Colin Braley to AUTHORS and CONTRIBUTORS.
2019-09-21 23:55:05 +03:00
Geoffrey Martin-Noble d2fc7fe659 Guard ASSERT_THROWS checks with BENCHMARK_HAS_NO_EXCEPTIONS (#874)
* Guard ASSERT_THROWS checks with BENCHMARK_HAS_NO_EXCEPTIONS

This allows the test be run with exceptions turned off

* Add myself to CONTRIBUTORS

I don't need to be added to AUTHORS, as I am a Google employee
2019-09-20 10:25:31 +01:00
sharpe5 bf4f2ea0bd Addresses issue #634. (#866)
* Update with instructions to build under Visual Studio

Fixes Issue #634.

I spent 3 days trying to build this library under Visual Studio 2017, only to discover on has to link to `Shlwapi.lib`.

Became so frustrated with the docs that I added full build instructions for Visual Studio 2015, 2017 and Intel Comiler 2015 and 2019.

* Update headings
2019-09-16 09:05:05 +01:00
Attila M. Szilagyi ef7d51c8eb Allow setting GOOGLETEST_PATH cmake argument. Fixes #867 (#868)
In `cmake/GoogleTest.cmake`, GOOGLETEST_PATH is default-initialized, but that init forgot to
account for the fact that the patch is explicitly supposed to be user-configurable.
By passing `CACHE` to `set()` we avoid that error.
2019-09-15 20:25:32 +03:00
Sayan Bhattacharjee 7ee72863fd Remove unused doc argument from DEFINE_ macros. (#857)
- Adresses : #856

  - The unused `doc` argument was removed from the `DEFINE_` macros in
    `commandlineflags.h`

  - Converted all the previous `doc` strings passed to the `DEFINE_`
    macros to multiline comments.
2019-08-21 14:12:03 -07:00
Sayan Bhattacharjee 67853d3ed8 Add .gitignore rule to ignore temporary .swp backup files created by vim. (#859)
- Addresses : #858

  - Rule `*.swp` is added to `.gitignore` to ensure that the vim temporary
    `.swp` backup files are ignored and they don't pollute the results of
    `git status -u`.
2019-08-21 13:53:15 -07:00
Sayan Bhattacharjee ffadb65d3a Documentation of basic use of DenseRange. (#855)
Documentation of basic use of `DenseRange` was added to README.md.
2019-08-21 09:51:31 -07:00
Roman Lebedev 3523f11d36
Update README.md: fix MS VS version requirement
VS2013 is unsupported since https://github.com/google/benchmark/pull/691 / eb8cbec077
but i forgot to update docs.
References:
* https://github.com/google/benchmark/issues/689
* https://github.com/google/benchmark/pull/691
* https://github.com/google/googletest/pull/1815
* https://github.com/google/benchmark/issues/853
* https://github.com/google/benchmark/pull/854
2019-08-21 15:14:27 +03:00
Roman Lebedev 7d97a057e1
Custom user counters: add invert modifier. (#850)
While current counters can e.g. answer the question
"how many items is processed per second", it is impossible to get
it to tell "how many seconds it takes to process a single item".

The solution is to add a yet another modifier `kInvert`,
that is *always* considered last, which simply inverts the answer.

Fixes #781, #830, #848.
2019-08-12 17:47:46 +03:00
Eric Fiselier c408461983 Disable deprecated warnings when touching CSVReporter internally.
The CSVReporter is deprecated, but we still need to reference it in
a few places. To avoid breaking the build when warnings are errors,
we need to disable the warning when we do so.
2019-08-07 15:55:40 -04:00
LesnyRumcajs 140fc22ab2 Corrected the installation procedure (#849)
* Corrected the installation procedure

Now it can be put into a script.

* Updated the file tree

Necessary after installation instruction change
2019-08-06 13:36:36 +03:00
Xinye Tao 140db8a229 fix typo in README (#844) 2019-07-30 09:03:15 +03:00
blackliner 66482d538d README.md: corrected cmake commands (#846)
* corrected cmake commands

* Update README.md
2019-07-29 23:59:25 +03:00
Boris Dergachov ff7e2d45a5 README.md: Spelling fix (#845) 2019-07-29 23:59:06 +03:00
Eric Backus 32a1e39720 Bugfix/wsl selftest fixes. Fixes #839 (#843)
* Update AUTHORS and CONTRIBUTORS

* Fix WSL self-test failures

Some of the benchmark self-tests expect and check for a particular
output format from the benchmark library. The numerical values must
not be infinity or not-a-number, or the test will report an error.
Some of the values are computed bytes-per-second or items-per-second
values, so these require that the measured CPU time for the test to be
non-zero. But the loop that is being measured was empty, so the
measured CPU time for the loop was extremely small. On systems like
Windows Subsystem for Linux (WSL) the timer doesn't have enough
resolution to measure this, so the measured CPU time was zero.

This fix just makes sure that these tests have something within the
timing loop, so that the benchmark library will not decide that the
loop takes zero CPU time. This makes these tests more robust, and in
particular makes them pass on WSL.
2019-07-27 19:02:31 +03:00
Roman Lebedev 8e48105d46 CMake; windows: link to lowercase 'shlwapi' - consistent with headers (#840)
The filenames are consistently inconsistent in windows world, might
have something to do with default file system being case-insensitive.
While the native MinGW buils were fixed in 5261307982
that only addressed the headers, but not libraries.
The problem remains when one tries to do a MinGW cross-build from
case-sensitive filesystem.
2019-07-22 13:42:12 +01:00
Jason Cooke df4f9fe362 docs: fix typo (#837) 2019-07-17 10:01:07 +03:00
Sam Elliott 4abdfbb802 Add RISC-V support in cycleclock::Now (#833)
The RISC-V implementation of `cycleclock::Now` uses the user-space
`rdcycle` instruction to query how many cycles have happened since the
core started.

The only complexity here is on 32-bit RISC-V, where `rdcycle` can only
read the lower 32 bits of the 64-bit hardware counter. In this case,
`rdcycleh` reads the higher 32 bits of the counter. We match the powerpc
implementation to detect and correct for overflow in the high bits.
2019-07-05 09:28:17 +01:00
Orgad Shaneh 04a9343fc9 Make some functions const (#832)
and ThreadManager ctor explicit.

Reported by CppCheck.
2019-06-26 09:06:24 +01:00
Roman Lebedev 090faecb45
Use IterationCount in one more place
Found in -UNDEBUG build
2019-05-13 22:42:18 +03:00
Roman Lebedev f92903cc53
Iteration counts should be uint64_t globally. (#817)
This is a shameless rip-off of https://github.com/google/benchmark/pull/646
I did promise to look into why that proposed PR was producing
so much worse assembly, and so i finally did.

The reason is - that diff changes `size_t` (unsigned) to `int64_t` (signed).

There is this nice little `assert`:
7a1c370283/include/benchmark/benchmark.h (L744)
It ensures that we didn't magically decide to advance our iterator
when we should have finished benchmarking.

When `cached_` was unsigned, the `assert` was `cached_ UGT 0`.
But we only ever get to that `assert` if `cached_ NE 0`,
and naturally if `cached_` is not `0`, then it is bigger than `0`,
so the `assert` is tautological, and gets folded away.

But now that `cached_` became signed, the assert became `cached_ SGT 0`.
And we still only know that `cached_ NE 0`, so the assert can't be
optimized out, or at least it doesn't currently.

Regardless of whether or not that is a bug in itself,
that particular diff would have regressed the normal 64-bit systems,
by halving the maximal iteration space (since we go from unsigned counter
to signed one, of the same bit-width), which seems like a bug.
And just so it happens, fixing *this* bug, fixes the other bug.

This produces fully (bit-by-bit) identical state_assembly_test.s
The filecheck change is actually needed regardless of this patch,
else this test does not pass for me even without this diff.
2019-05-13 12:33:11 +03:00
Roman Lebedev 2e7203aa94
CMake: check CMAKE_CXX_COMPILER_ID, not CMAKE_C_COMPILER_ID
This may or may not have gotten broken now that benchmark was marked as CXX-only.
2019-05-11 18:57:41 +03:00
Michał Janiszewski 12c978c513 Mark CMake project as C++-only (#681)
This will make CMake skip all the checks for C compiler.
2019-05-10 19:56:08 +03:00
Michał Janiszewski b988639f31 Fix compilation for Android (#816)
Android doesn't support `getloadavg`
2019-05-09 15:22:13 -07:00
Roman Lebedev 33d4404650 Don't read CMAKE_BUILD_TYPE if it is not there (#811)
Weird, but seems consistent with the rest of cmake here.
2019-05-07 16:06:50 -07:00
Shuo Chen 7d856b0304 If gtest targets are already defined, use them. (#777)
This allows a project to include both googletest and benchmark as top-level git submodule.

This allows incorporating Benchmark to an existing CMake project that already incorporates googletest.
https://github.com/google/googletest/blob/master/googletest/README.md#incorporating-into-an-existing-cmake-project
https://github.com/abseil/abseil-cpp/tree/master/CMake#incorporating-abseil-into-a-cmake-project
2019-05-01 23:00:10 +03:00
Lockywolf 823d24630d Add support for GNU Install Dirs from GNU Coding Standards. Fixes #807 (#808)
* Add support for GNU Install Dirs from GNU Coding Standards

* src/CMakeLists.txt: Added support for setting the standard variables,
                      such as CMAKE_INSTALL_BINDIR.

* Replace install destinations by the ones from GNU Coding Standards.

* Set the default .cmake and .pc default path.
2019-05-01 09:13:33 +01:00
Dominic Hamon 13b8bdc2b5
Bump required cmake version from 2.x to 3.x (#801) 2019-05-01 09:06:12 +01:00
Roman Lebedev 94115f4419
Revert "Travis-ci: more correctly pass -m32 to 32-bit jobs"
Very interesting, i was completely not expecting to see that cmake
failure from https://github.com/google/benchmark/pull/801 *here*.

This reverts commit 7da47d039d.
2019-04-30 21:07:01 +03:00
Roman Lebedev 7da47d039d
Travis-ci: more correctly pass -m32 to 32-bit jobs
Generally we can't just add -m32 in the middle of the build.
It currently just happens to work, but that is not guaranteed.
2019-04-30 20:32:03 +03:00
Roman Lebedev 727a81aabd
CMake: avoid incorrect extra "" around the GOOGLETEST_PATH.
It was looking in `"<...>/googlebenchmark/build/third_party/googletest"`,
with these extra `"` quotes, and wasn't finding anything..
2019-04-30 19:33:09 +03:00
Roman Lebedev 4b77194032
CMake: codedrop of googletest cmake magic from me (#809)
https://github.com/google/benchmark/pull/801 is stuck with some cryptic cmake failure due to
some linking issue between googletest and threading libraries.

I suspect that is mostly happening because of the, uhm,
intentionally extremely twisted-in-the-brains approach that is being used to
actually build the library as part of the buiild,
except without actually building it as part of the build.

If we do actually build it as part of the build,
then all the transitive dependencies should magically be in order,
and maybe everything will just work.

This new version of cmake magic was written by me in
0e22f085c5/cmake/Modules/GoogleTest.cmake.in
0e22f085c5/cmake/Modules/GoogleTest.cmake, based on the official googletest docs and LOTS of experimentation.
2019-04-30 13:36:29 +03:00
astee 05d8c1c5d0 Improve README (#804)
* Update and organize README

* Update AUTHORS and CONTRIBUTORS

Fixes #803.
2019-04-25 14:48:56 +03:00
Michael Tesch 588be0446a escape special chars in csv and json output. (#802)
* escape special chars in csv and json output.

- escape \b,\f,\n,\r,\t,\," from strings before dumping
  them to json or csv.
- also faithfully reproduce the sign of nan in json.
this fixes github issue #745.

* functionalize.

* split string escape functions between csv and json

* Update src/csv_reporter.cc

Co-Authored-By: tesch1 <tesch1@gmail.com>

* Update src/json_reporter.cc

Co-Authored-By: tesch1 <tesch1@gmail.com>
2019-04-19 18:47:25 +01:00
Dominic Hamon 1d41de8463
Add command line flags tests (#793)
Increase coverage
2019-04-17 17:08:52 +01:00
Hannes Hauswedell 415835e03e fix master branch on *BSD (#792)
* fix master branch on *BSD

* add name to CONTRIBUTORS
2019-04-11 16:36:11 +01:00
Jusufadis Bakamovic 56fd56dc02 Refactor U-Test calculation into separate function. (#740)
* Refactor U-Test calculation into separate function.

And implement 'print_utest' functionality in terms of it.

* Change 'optimal_repetitions' to 'more_optimal_repetitions'.
2019-04-11 10:48:29 +01:00
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