* Refactor benchmark.cc into benchmark_register.cc and benchmark_run.cc
The benchmark.cc file is getting really big and it contains a bunch of
unrelated components. This patch separates the files into two separate
parts. The "runtime" parts and the "registration" parts.
This patch also removes the PIMPL used by Benchmark. Previously we couldn't
have STL types in the interface but now we can. Therefore there is no reason
to keep BenchmarkImp.
* add missing include
* rework windows timers again
* Guard timespec on older Windows versions
* Remove old thread safety annotation workarounds
* Change to using per-thread timers
* fix bad assertions
* fix copy paste error on windows
* Fix thread safety annotations
* Make null-log thread safe
* remove remaining globals
* use chrono for walltime since it is thread safe
* consolidate timer functions
* Add missing ctime include
* Rename to be consistent with Google style
* Format patch using clang-format
* cleanup -Wthread-safety configuration
* Don't trust _POSIX_FEATURE macros because OS X lies.
* Fix OS X thread timings
* attempt to fix mingw build
* Attempt to make mingw work again
* Revert old mingw workaround
* improve diagnostics
* Drastically improve OS X measurements
* Use average real time instead of max
Add policy CMP0056, which honors the link flags in try_compile and
try_run. This allows for building against non-system libc++ by providing
the correct -L and rpath options in a containing project.
For example:
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L ${LLVM_ROOT}/lib -l c++ -l c++abi")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-rpath,${LLVM_ROOT}/lib")
In addition to release, CMake supports RELWITHDEBINFO and MINSIZEREL
build configurations. In particular, debug info is necessary for many
profilers to do anything useful, making RELWITHDEBINFO important here.
MINSIZEREL was added for completeness' sake.
BENCHMARK_ENABLE_LTO=true was completely replacing
CMAKE_CXX_FLAGS_RELEASE; meaning neither CMake's release defaults nor
user customizations were being applied.
This change looks for CMake's default setting for MSVC++, /W3 (and any
other level should that change in the future), and removes it before
adding /W4. This stops the build for MSVC++ emitting warnings about
/W4 overriding /W3 earlier on the command line.
This also points out some important issues like:
warning: conversion to 'size_t {aka unsigned int}' from 'long long int' may alter its value [-Wconversion]
state.SetBytesProcessed(items_processed * sizeof(v));
This occurs on 32 bit systems where size_t is only 32 bits.
This patch adds a `coverage` target that allows coverage statisitics to be
retrieved for the project. It requires that lcov and gcov is installed and
that the generator is unix makefiles but this can be improved upon in
future releases.
To make it work use the coverage build type:
```
cmake -DCMAKE_BUILD_TYPE=Coverage .
make coverage
```
This improves development iterations when working in debug mode as you
don't have to fix up warnings to get the code to compile. Once a feature
is complete you can then run a release build and fix up all the warnings.
This patch adopts a new internal structure for how timings are performed.
Currently every iteration of a benchmark checks to see if it has been running
for an appropriate amount of time. Checking the clock introduces noise into
the timings and this can cause inconsistent output from each benchmark.
Now every iteration of a benchmark only checks an iteration count to see if it
should stop running. The iteration count is determined before hand by testing
the benchmark on a series of increasing iteration counts until a suitable count
is found. This increases the amount of time it takes to run the actual benchmarks
but it also greatly increases the accuracy of the results.
This patch introduces some breaking changes. The notable breaking changes are:
1. Benchmarks run on multiple threads no generate a report per thread. Instead
only a single report is generated.
2. ::benchmark::UseRealTime() was removed and replaced with State::UseRealTime().
This patch cleans up our use of generic macros and also merges changes in the
build system.
It adds options -DBENCHMARK_ENABLE_TESTING and -DBENCHMARK_ENABLE_SHARED.
This patch automatically versions the shared libraries from any annotated `git`
tags:
```
git tag -a v1.0.0
```
It expects semver version tags such as `v1.0.0`. It would be trivial to support
`1.0.0` but looking around it seems that most C/C++ projects follow `vX.X.X`
rather that `X.X.X` like a lot of `Node.js` stuff.
This determines that the if the project has had a certain amount of commits
since the last tag and also if the project is _dirty_ (has modified files), but
does __nothing__ with that information. In the future a more robust release
could be implemented in the script.
This is pretty brittle and has little in the way of configuration. Ideally we
should use `find_program` to work out where `git` is so that users can configure
it. This implementation assumes that `git` will be available in `PATH`
Outputs the following on the command line:
```
-- git Version: v[MAJOR].[MINOR].[PATCH]-[COMMITS_SINCE_TAG]-[SHA1](-dirty)?
-- Version: [MAJOR].[MINOR].[PATCH]
```