Commit Graph

706 Commits

Author SHA1 Message Date
Joao Paulo Magalhaes 86249c57a5 Result checking: move some function definitions to source file. 2017-04-29 19:40:39 +01:00
Joao Paulo Magalhaes 03b0655d12 Fix expected values of user counters as rates in unit tests. 2017-04-29 19:35:43 +01:00
Joao Paulo Magalhaes 921a51abcf Console reporting of user counters: print rates like non-rates. 2017-04-29 19:34:37 +01:00
Joao Paulo Magalhaes 5ed1b1dea7 Merge branch 'master' of https://github.com/vladoovtcharov/benchmark into test_usercounters 2017-04-29 19:27:53 +01:00
Joao Paulo Magalhaes 78548f8c6e Add (currently failing) tests for user counters with threads. 2017-04-29 19:26:34 +01:00
Joao Paulo Magalhaes 2814e9d8dc Fix ResultsCheckerEntry::NumThreads() 2017-04-29 19:25:51 +01:00
Joao Paulo Magalhaes 92034a8b84 Make result checkers execute on all regex-matching benchmarks. 2017-04-29 19:02:07 +01:00
Joao Paulo Magalhaes 738fcd9e6a Add log of the benchmark name when checking results. 2017-04-29 18:30:28 +01:00
Joao Paulo Magalhaes 1ce286f632 Avoid compiler-specific pragmas in result check macros.
- Epsilon is now understood as relative to expected value.
- Improve error messages for epsilon checks.
2017-04-29 18:26:30 +01:00
Joao Paulo Magalhaes da69e5de45 User counters: add more tests. 2017-04-28 20:45:30 +01:00
Joao Paulo Magalhaes 8c757a3bb9 Results check: add checks with epsilon. 2017-04-28 20:44:27 +01:00
Joao Paulo Magalhaes 1826feb164 ResultsCheckerEntry: add more getter functions. 2017-04-28 20:43:44 +01:00
Joao Paulo Magalhaes 2a8d0dd1b1 Use const char* instead of std::string in entry name lookup. 2017-04-28 20:42:28 +01:00
Joao Paulo Magalhaes 8adf59d762 Add epsilon check macros for float comparison. 2017-04-28 20:40:21 +01:00
Joao Paulo Magalhaes e869e3749a Remove some whitespace. 2017-04-28 15:38:21 +01:00
Joao Paulo Magalhaes 6452883027 Unit testing: add facilities to check benchmark results.
This is needed for examining the values of user counters (needed
for #348). It is also needed for checking the values of standard
benchmark results like items_processed or complexities (for example,
checking the standard deviation is needed for unit testing #357
as discussed in #362).
2017-04-28 15:02:27 +01:00
Joao Paulo Magalhaes 693a43013d User counters: add more unit tests. ...
The tests are still missing a way to check actual validity of
numerical results; this will be done next. As they currently are,
the tests pass, but the problem detected with #378 is still
standing and the results with non-standard counters are wrong.
2017-04-27 22:11:40 +01:00
Joao Paulo Magalhaes 3c2d7f5348 User counter tests: first version. 2017-04-27 19:25:20 +01:00
Joao Paulo Magalhaes b273d9b7d5 Reporter tests: reuse csv header. 2017-04-27 19:24:06 +01:00
Joao Paulo Magalhaes 409f35da50 User counters: fix misplaced newline in console reporter header. 2017-04-27 19:22:36 +01:00
vladoovt 1295ce8f23 Fixes #378 coercion to double was causing counter to forget its flags, changed it so that its value is updated directly 2017-04-27 09:56:43 -06:00
Joao Paulo Magalhaes 2d1a34626f Fixes #378 (hopefully). Unit tests for counters to follow.
The problem was that the call to Finish() the user counters was
lost in a big merge. If I had already written the tests for the
user counters, this would probably have been catched earlier.
2017-04-27 13:16:49 +01:00
Joao Paulo Magalhaes 27b3bd4dc4 Merge branch 'master' of https://github.com/google/benchmark 2017-04-27 12:38:28 +01:00
Arkady Shapkin 3336ea00d8 Support VS2017 on AppVeyor (#376) 2017-04-24 10:45:24 -07:00
Dmitry Trifonov 7a74b74856 fix for android NDK r10e (#375) 2017-04-20 20:07:52 -06:00
Dmitry Trifonov 09b93ccc6a fix android compilation (#372)
* fix android compilation

* checking __GLIBCXX__ and __GLIBCPP__ macro in addition to __ANDROID__

* using vsnprintf instead of std::vsnprintf to compile on Android

* removed __GLIBCPP__ check on Android

* StringPrintF instead of std::to_string for Android
2017-04-18 09:48:07 -06:00
Eric Fiselier 46afd8e693 Don't limit benchmarks with manual timers to 5x the elapsed real time.
When using CPU time to determine the correct number of iterations the
library additionally checks if the benchmark has consumed 5x the minimum
required time according to the wall clock. This prevents benchmarks
with low CPU usage from running for much longer than actually intended.

However when a benchmark uses a manual timer this heuristic isn't helpful
and likely isn't correct since we don't know what the manual timer actually
measures.

This patch removes the above restriction when a benchmark specifies a manual
timer.
2017-04-18 00:13:18 -06:00
Eric 74b24058ad Add Benchmark::Iterations for explicit iteration count control - Fixes #370 (#373)
* Add Benchmark::Iterations for explicitly specifying the number of iterations to use.

* Document that benchmark::Iterations should not be used to limit benchmark runtimes
2017-04-17 21:29:28 -07:00
Eric Fiselier 7f87c98d36 Enable <cassert> by removing -DNDEBUG when running the tests.
In non-debug builds CMake automatically adds -DNDEBUG, this means
that uses of `assert` in the tests are disabled for non-debug builds.
Obviously we want these tests to run, regardless of configuration.

This patch strips -DNDEBUG during non-debug builds and adds
-UNDEBUG just to be sure.
2017-04-17 20:53:39 -06:00
Daniel Varga 312d9d0ac5 Fix cmake file not to use CMAKE_SOURCE_DIR (#367)
Using CMAKE_SOURCE_DIR benchmark cannot be built as part of a project.
This change allows to add benchmark using add_subdirectory to a bigger
project.
2017-04-10 08:43:05 -07:00
Joao Paulo Magalhaes 9986589fff Merge branch 'master' of https://github.com/google/benchmark 2017-04-06 14:12:09 +01:00
jpmag 9a5072d1bf Fixes #357: broken RMS values when time unit is set. (#362) 2017-04-04 12:31:28 -07:00
Dominic Hamon 2fa6dfff32 Merge branch 'piribes-1.1' 2017-04-04 08:39:10 -07:00
Dominic Hamon 858581ea76 Remove unnecessary benchmark subfolder 2017-04-04 08:39:02 -07:00
Dominic Hamon 66283598e6 Merge branch '1.1' of git://github.com/piribes/benchmark into piribes-1.1 2017-04-04 08:35:51 -07:00
Giuseppe Roberti 128fe25025 Fix ${include_install_dir} 2017-04-04 02:13:20 +02:00
Giuseppe Roberti 824bbb818e Add CMake Package Config files during install
- Remove target_include_directories of ${PROJECT_SOURCE_DIR}/include to
  fix error: Target "benchmark" INTERFACE_INCLUDE_DIRECTORIES property
  contains path which is prefixed in the source directory.
2017-04-03 01:54:24 +02:00
Joao Paulo Magalhaes ea26e62a0d Fixes #357: broken RMS values when time unit is set. 2017-04-01 17:04:37 +01:00
Ray Glover 17298b2dc0 Python 2/3 compatibility (#361)
* [tools] python 2/3 support

* update authors/contributors
2017-03-29 03:39:18 -07:00
Eric 0dbcdf56a0 Add BENCHMARK_BUILD_32_BITS option and add builders to test it (#360)
* Add BENCHMARK_BUILD_32_BITS option and add builders to test it

* Attempt to fix travis configuration

* Make add_required_cxx_compiler_flag cause an error when the flag isn't supported

* add gcc-multilib dependancy on travis

* attempt to fix travis.yml parsing error

* Require g++-multilib instead of gcc-multilib

* Add 32 bit release configurations

* Attempt to fix libc++ travis build w/ 32 bits

* Work around CMake configuration failure on Travis
2017-03-28 00:43:42 -07:00
MVafin ec15860da5 Fix CPU frequency parsing on Linux (#355) (#356)
* Fix reading CPU info from file

Macro CHECK do nothing for release mode, meaning it doesn't invoke the
arguments

* Add myself to AUTHORS and CONTRIBUTORS
2017-03-28 00:35:17 -06:00
Eric 94c512c043 Replace int64_t usages with 'int' instead. (#359)
Previously the constants used for converting between
different units of time were declared using int64_t. However
we should only use explicitly sized integer types when they
are required, and should use 'int' everwhere else, and there is
no good reason to use int64_t here.

For that reason this patch changes the type of the constants.
This should help address issue #354 as well.
2017-03-27 18:32:12 -06:00
rolandschulz 9b92ed76a8 Fix ICC compiler warnings (#358)
fixes #354

The build fails with ICC17 because of warnings and Werror. What is the correct solution to fix it?
Should a patch

disable Werror for ICC (or maybe all non known compilers)
disable the false postive warnings for all files. This could be done using:
add_cxx_compiler_flag(-wd2102) #ICC17u2: Many false positives for Wstrict-aliasing
add_cxx_compiler_flag(-wd2259) #ICC17u2: non-pointer conversion from "long" to "int" may lose significant bits (even for explicit static cast, sleep.cc(44))
add_cxx_compiler_flag(-wd654) #ICC17u2: overloaded virtual function "benchmark::Fixture::SetUp" is only partially overridden (because of deprecated overload)
disable warnings at file level or some other granularity
2017-03-27 18:30:54 -06:00
Yasushi Saito f5ff6d0e0d Include cstdlib for timespec. Clang modules demands that. (#353) 2017-03-13 20:30:19 -06:00
Eric f682f7e9a4 Implement ClobberMemory() and fix DoNotOptimize on MSVC. (#352)
I recently learned Windows provides a function called _ReadWriteBarrier
which is literally ClobberMemory under a different name. This patch
uses it to implement ClobberMemory under MSVC.
2017-03-10 18:47:39 -07:00
Eric Fiselier 8ae6448cc7 Fix std::string detection hack for SetLabel.
Previously benchmark_api.h wasn't allowed to include standard library
headers. For this reason SetLabel had a hack to accept std::string
without including <string>. The hack worked by attempting to detect
the injected class name `basic_string`. However Clang has changed
it's behavior regarding injected class names so this hack no longer
works.

This patch removes the hack and replaces it with a function that
actually names std::string. However we still cannot pass std::string
across the dylib boundary because of libstdc++'s dual C++11 ABI.
2017-03-10 17:52:02 -07:00
jpmag 9e34655602 Rename BenchmarkCounters to UserCounters (#346)
The name UserCounters seems more accurate than the pleonastic BenchmarkCounters.
2017-03-01 17:50:19 -07:00
jpmag a9a66c85bb Add user-defined counters. (#262)
* Added user counters, and move use of bytes_processed and items_processed to user counter logic.

Each counter is a string-value pair. The counters were
made available through the State class. Two helper virtual
methods were added to the Fixture class to allow convenient
initialization and termination of the counters: InitState()
and TerminateState(). The reporting of the counters is buggy
and is still a work in progress, to be completed in the next commits.

* fix bad removal of BenchmarkCounters code during the merge

* add myself to AUTHORS/CONTRIBUTORS

* fix printing to std::cout in csv_reporter

* bytes_per_second and items_per_second are now in the UserCounters class

* add user counters to json reporter

* moving bytes_per_second and items_per_second to their old state

* console reporter dealing ok with user counters.

* update unit tests for user counters

* CSVReporter now prints user counters too.

* cleanup user counters

* reverted changes to cmake files which should have gone into later commits

* fixture_test: fix gcc 4.6 compilation

* remove ctor with default argument

see https://github.com/google/benchmark/pull/262#discussion_r72298055

* use (auto-defined) BENCHMARK_HAS_CXX11 instead of BENCHMARK_INITLIST.

https://github.com/google/benchmark/pull/262#discussion_r72298310

* leanify counters API

Discussions:
API complexity: https://github.com/google/benchmark/pull/262#discussion_r72298731
remove std::string dependency (WIP): https://github.com/google/benchmark/pull/262#discussion_r72298142
spacing & alignment: https://github.com/google/benchmark/pull/262#discussion_r72298422

* remove std::string dependency on public API - changed counter name storage to char*

* Counter ctor: use overloads instead of default arguments

discussion:
https://github.com/google/benchmark/pull/262#discussion_r72298055

* Use raw pointers to remove dependency on std::vector from public API .

For more info, see discussion at https://github.com/google/benchmark/pull/262#discussion_r72319678 .

* Move counter implementation from benchmark.cc to counter.cc.

    See discussion: https://github.com/google/benchmark/pull/262#discussion_r72298980 .

* Remove unused (commented-out) code.

* Moved thread counters to ThreadStats.

* Counters: fixed copy and move constructors.

* Counter: use an inplace buffer for small names.

* benchmark_test: move counters test out of CXX11 preprocessor conditional.

* Counter: fix VS2013 compilation error in char[] initialization.

* Fix typo.

* Expose counters from State.

See discussion: https://github.com/google/benchmark/pull/262#issuecomment-237156951

* Changed counters interface to map-like.

* Fix printing of user counters in ConsoleReporter.

* Applied clang-format to counter.cc and console_reporter.cc.

Command was `clang-format -style=Google -i counter.cc console_reporter.cc`
I also applied to all other files, but the changes were very
far-reaching so I rolled those back.

* Rename Counter::Flags_e to Counter::Flags

* Fix use of reserved names in Counter and BenchmarkCounters.

* Counter: Fix move ctor bug + change order of members.

* Fixture: remove tentative methods InitState() and TerminateState().

* Update fixture_test to the new Fixture interface.

* BenchmarkCounters: fixed a bug in the move ctor. Remove call to CHECK_LT().

CHECK_LT() was making the size_t lookup take ~double the time of a string lookup!

* BenchmarkCounters: add option to not print zero counters (defaults to false).

* Add test to compare counter storage and access with std::map.

* README: clarify cost of counter access modes.

* move counter access test to an own test.

* BenchmarkCounters: add move Insert()

* Counters access test: add accelerated lookup by name.

* Fix old range syntax.

* Fix missing include of cstdio

* Fix Visual Studio warning

* VS2013 and lower: fix use of snprintf()

* VS2013: fix use of char[] as a member of std::pair<>.

* change counter storage to std::map

* Remove skipZeroCounters logic

* Fix VS compilation error.

* Implemented request changes to PR #262.

* PR #262: More requested changes.

* README: cleanup counter text.

* PR #262: remove clang-format changes for preexisting code

* Complexity+Counters: fix counter flags which were being ignored.

* Document all Counter::Flag members

* fixed loss of counter values

* ConsoleReporter: remove tabular printing of user counters.

* ConsoleReporter: header printing should not be contingent on user counter names.

* Minor white space and alignment fixes.

* cxx03_test + counters: reuse the BM_empty() function.

* user counters: add note to README on how counters are gathered across threads
2017-03-01 17:23:42 -07:00
Marat Dukhan 070c0ca0a9 Support for Web platforms (#340)
* Implement cycleclock::Now for PNaCl

* Make cycleclock::Now compatible with NaCl/ARM

* Support Emscripten (Asm.js, WebAssembly)

* Rearrange #ifs from to handle specific cases first

* DoNotOptimize without inline asm for Emscripten & PNaCl
2017-02-11 03:31:40 -07:00
guray fef203bd02 Fix typename for powerpc (#337) 2017-01-30 12:50:21 -08:00