Commit graph

1183 commits

Author SHA1 Message Date
Kai Wolf 56898e9a92
Add missing <cerrno> header include - fixes Android build (#960)
* Add missing <cerrno> header

This commit fixes a current build error on Android where 'errno' is an unidentified
symbol due to a missing header

* Update string_util.cc

Conditionally adds <cerrno> if BENCHMARK_STL_ANDROID_GNUSTL is defined
2020-04-23 14:19:19 +03:00
Luís Marques ecc1685340
Fix formatting issues introduced by a77d5f7 (#959) 2020-04-17 19:31:49 +03:00
Keith Moyer 8cead00783
Remove warnings for internal use of CSVReporter (#956)
In a previous commit[1], diagnostic pragmas were used to avoid this
warning. However, the incorrect warning flag was indicated, leaving the
warning in place. -Wdeprecated is for deprecated features while
-Wdeprecated-declarations for deprecated functions, variables, and
types[2].

[1] c408461983
[2] https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
2020-04-14 10:20:22 +01:00
Luís Marques a77d5f70ef
Fix cycleclock::Now for RISC-V and PPC (#955)
Fixes the following issues with the implementation of `cycleclock::Now`:

- The RISC-V implementation wouldn't compile due to a typo;

- Both the PPC and RISC-V implementation's asm statements lacked the
  volatile keyword. This resulted in the repeated read of the counter's
  high part being optimized away, so overflow wasn't handled at all.
  Multiple counter reads could also be misoptimized, especially in LTO
  scenarios.

- Relied on the zero/sign-extension of inline asm operands, which isn't
  guaranteed to occur and differs between compilers, namely GCC and Clang.

The PowerPC64 implementation was improved to do a single 64-bit read of
the time-base counter.

The RISC-V implementation was improved to do the overflow handing in
assembly, since Clang would generate a branch, defeating the purpose
of the non-branching counter reading approach.
2020-04-10 17:02:13 +01:00
Dominic Hamon 0ab2c2906b
Fix type conversion warnings. (#951)
* Fix type conversion warnings.

Fixes #949

Tested locally (Linux/clang), but warnings are on MSVC so may differ.

* Drop the ULP so the double test passes
2020-04-06 13:52:09 +01:00
Konstantin Khlebnikov b23d35573b
Fix Travis-ci builds (#950)
Line "- /usr/local/bin:$PATH" is misformatted.
It must be something like "- PATH=/usr/local/bin:$PATH".

It seems something changed in tarvis-ci month ago and now this leads to:

Setting environment variables from .travis.yml
$ export PATH=

Defailt PATH is /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin
so already containts /usr/local/bin.


Image "xcode8.3" contains macOS 10.12 (sierra) which has no bottles
with precompiled gcc-7 in homebrew storage.

Image "xcode9.4" is a current default with macOS 10.13 (high_sierra).

Link: https://docs.travis-ci.com/user/reference/osx/
Link: https://formulae.brew.sh/formula/gcc@7

Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
2020-03-30 09:22:37 +03:00
Roman Lebedev e30cac6b06
Revert "Add d postfix to Debug libraries (#923)" (#947)
This reverts commit 5ce2429af7.

Reverts https://github.com/google/benchmark/pull/923
Reopens https://github.com/google/benchmark/issues/922
Fixes https://github.com/google/benchmark/issues/928
Closes https://github.com/google/benchmark/pull/930

See discussion in https://github.com/google/benchmark/issues/928
this broke pkg-config support, since there we don't account
for the suffix, nor is it trivial to do so.
2020-03-16 14:32:08 +03:00
Roman Lebedev 70d89ac519
Revert "Add d postfix to Debug libraries (#923)"
This reverts commit 5ce2429af7.

Reverts https://github.com/google/benchmark/pull/923
Reopens https://github.com/google/benchmark/issues/922
Fixes https://github.com/google/benchmark/issues/928
Closes https://github.com/google/benchmark/pull/930

See discussion in https://github.com/google/benchmark/issues/928
this broke pkg-config support, since there we don't account
for the suffix, nor is it trivial to do so.
2020-03-16 14:29:27 +03:00
Dominic Hamon 8e0b1913d4 Update issue templates 2020-02-25 11:21:58 +00:00
Paweł Bylica c078337494
Relax CHECK condition in benchmark_runner.cc (#938)
* Add State::error_occurred()

* Relax CHECK condition in benchmark_runner.cc

If the benchmark state contains an error, do not expect any iterations has been run.
This allows using SkipWithError() and return early from the benchmark function.

* README.md: document new possible usage of SkipWithError()
2020-02-21 17:53:25 +03:00
Nick 168604d8f8
[docs] Use benchmark::IterationCount rather than int64_t in lambda to complexity (#940) 2020-02-18 15:04:45 +03:00
Ben Clayton 8982e1ee6a
Fix MSVC warning. (#935)
This fixes the Visual Studio 2019 warning:

`C4244: '=': conversion from 'int' to 'char', possible loss of data`

When implicitly casting the return value of tolower() (int) to char.

Fixes: #932
2020-02-08 02:48:01 +03:00
Alex Reinking e5ea03ce07
Fix cxx03 standard selection, option override in CMake 3.13+. Fixes #933 (#934) 2020-01-31 10:16:25 +00:00
Dominic Hamon 5ac80de037 Disable pedantic warnings and errors until googletest/gmock is fixed 2020-01-30 13:29:17 +00:00
Jordan Williams daff5fead3 Alias CMake Targets. Fixes #921 (#926)
* add Jordan Williams to both CONTRIBUTORS and AUTHORS

* alias benchmark libraries

Provide aliased CMake targets for the benchmark and benchmark_main targets.
The alias targets are namespaced under benchmark::, which is the namespace when they are exported.
I chose not to use either the PROJECT_NAME or the namespace variable but to hard-code the namespace.
This is because the benchmark and benchmark_main targets are hard-coded by name themselves.
Hard-coding the namespace is also much cleaner and easier to read.

* link to aliased benchmark targets

It is safer to link against namespaced targets because of how CMake interprets the double colon.
Typo's will be caught by CMake at configuration-time instead of during compile / link time.

* document the provided alias targets

* add "Usage with CMake" section in documentation

This section covers linking against the alias/import CMake targets and including them using either find_package or add_subdirectory.

* format the "Usage with CMake" README section

Added a newline after the "Usage with CMake" section header.
Dropped the header level of the section by one to make it a direct subsection of the "Usage" section.
Wrapped lines to be no longer than 80 characters in length.
2020-01-14 23:21:24 +03:00
Szitár Gergő 5ce2429af7 Add d postfix to Debug libraries (#923)
* Add DEBUG_POSTFIX to libraries.

Makes it possible to install Debug and Release versions on the
same system. Without this, there were only linker errors when using
the wrong configuration.

* Update CONTRIBUTORS and AUTHORS according to guide
2020-01-05 12:32:40 +00:00
Tetsuo Kiso 0811f1d782 Fix typo in mutex.h (#917) 2019-12-15 13:38:54 +03:00
Roman Lebedev 367119482f CPU caches are binary units, not SI. (#911)
As disscussed in https://github.com/google/benchmark/issues/899,
it is all but certain that the multiplier should be 1024, not 1000.

Fixes https://github.com/google/benchmark/issues/899
2019-12-02 09:29:16 +00:00
Roman Lebedev 318d07113d
README.md: a few adjustments after #894 2019-12-01 13:42:52 +03:00
Martin Blanchard daf276ff94 Document environment variables options usage (#894)
See https://github.com/google/benchmark/issues/881
2019-12-01 13:40:10 +03:00
Dominic Hamon 49aa79b635
update header guard to match style 2019-11-25 13:05:13 +00:00
Roman Lebedev a8b3693321
Merge pull request #905 from LebedevRI/misc-cleanup
Fix some issues seen in some static analysis reports
2019-11-23 01:53:34 +03:00
Roman Lebedev 51d991f1d7
ParseCommandLineFlags(): do not dereference argc if it is null
Higher up we dereference argc only if it is not null.
But here we do no such check.
2019-11-23 00:23:11 +03:00
Roman Lebedev c22c266eaf
JSONReporter: RoundDouble(): use std::lround() to round double to int
From clang-tidy bugprone-incorrect-roundings check:
> casting (double + 0.5) to integer leads to incorrect rounding; consider using lround (#include <cmath>) instead
2019-11-23 00:19:02 +03:00
Roman Lebedev cc7f50e126
BenchmarkRunner: use std::lround() to round double to int
From clang-tidy bugprone-incorrect-roundings check:
> casting (double + 0.5) to integer leads to incorrect rounding; consider using lround (#include <cmath>) instead
2019-11-23 00:18:28 +03:00
Roman Lebedev 74e112ae9d
mingw.py: check for None via 'is', not '=='. 2019-11-22 23:39:56 +03:00
Roman Lebedev 173aff82ee
src/counter.h: add header guard 2019-11-22 15:06:43 +03:00
Gregor Jasny c50ac68c50 CMake: use full add_test(NAME <> COMMAND <>) signature (#901)
* CTest must use proper paths to executables

With the following syntax:

```
  add_test(NAME <name> COMMAND <command> [<arg>...])
```

if `<command>` specifies an executable target it will automatically
be replaced by the location of the executable created at build time.

This is important if a `<Configuration>_POSTFIX` like `_d` is used.

* Fix typo in ctest invocation

Instead of `-c` the uppercase `-C` must be used to select a config.
But better use the longopt.
2019-11-05 22:46:13 +03:00
András Leitereg cf446a18bf Remove superfluous cache line scaling in JSON reporter. (#896)
Cache size is already stored in bytes.
2019-10-24 22:13:03 +03:00
Kyle Edwards d16ae64e5a Set CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS (#889)
When building on Windows with `BUILD_SHARED_LIBS=ON`, the symbols were
not being properly exported in the DLL. Fix this by setting
`CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS`.

Fixes #888
2019-10-23 11:13:40 +03:00
Martin Blanchard bc200ed8ee Read options from environment (#881) (#883)
Initialize option flags from environment variables values if they are defined, eg. `BENCHMARK_OUT=<filename>` for `--benchmark_out=<filename>`. Command line flag value always prevails.

Fixes https://github.com/google/benchmark/issues/881.
2019-10-23 11:07:08 +03:00
Paul Wankadia 309de5988e Switch to Starlark for C++ rules. (#887)
While I'm here, format all of the files that I touched.
2019-10-08 11:09:51 +01:00
Kyle Edwards f4f5dba46b Cache RUN_${FEATURE} variable in CXXFeatureCheck.cmake (#886)
When cross-compiling, this variable was not set on the second run
of CMake, resulting in the next check failing even though it shouldn't
be run in the first place. Fix this by caching the variable.
2019-10-04 09:50:53 +01:00
Chunsheng Pei b8bce0c7ed fixed the param order in g++ command and fixed the path for -L (#879)
* fixed the param order in g++ command and fixed the path for -L

* reorder the parameters for g++ command
2019-09-27 12:09:23 +01:00
Geoffrey Martin-Noble b874e72208 Guard definition of __STDC_FORMAT_MACROS in ifndef (#875)
This macro is sometimes already defined and redefining it results
in build errors.
2019-09-23 10:53:09 +01:00
Geoffrey Martin-Noble 7411874d95 Define HOST_NAME_MAX for NaCl and RTEMS (#876)
These OS's don't always have HOST_NAME_MAX defined, resulting in
build errors.

A few related changes as well:
* Only define HOST_NAME_MAX if it's not already defined. There are
  some cases where this is already defined, e.g. with NaCl if
  __USE_POSIX is set. To avoid all of these, only define it if it's
  not already defined.
* Default HOST_NAME_MAX to 64 and issue a #warning. Having the wrong
  max length is pretty harmless. The name just ends up getting
  truncated and this is only for printing debug info. Because we're
  constructing a std::string from a char[] (so defined length), we
  don't need to worry about gethostname's undefined behavior for
  whether the truncation is null-terminated when the hostname
  doesn't fit in HOST_NAME_MAX. Of course, this doesn't help people
  who have -Werror set, since they'll still get a warning.
2019-09-23 10:38:34 +01:00
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