Commit graph

687 commits

Author SHA1 Message Date
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
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
Matt Sieren 246ee86428 Disable iOS CPU Frequency readout (#335)
* Add macro definition for iOS

Add an additional macro definition for iOS.
iOS is defined as a Mac OSX invariant in the TargetConditionals include,
thus we treat it as a subset of OSX within the defines.

* Skip error for hw.cpufrequency on iOS

hw.cpufrequency is not available on iOS devices. As there is no way to reliably
retrieve the CPU frequency on iOS we are printing out a warning
that we were unable to detect the CPU frequency and set it to 0.

This only disables cpu frequency readouts on actual physical iOS devices.
Running this code on the simulator still gives the cpu architecture of
the host computer as the simulator passes down the sysctl calls to OSX.
2017-01-24 11:31:14 -08:00
Niklas Rosenstein 817bfee273 Report unrecognized arguments from BENCHMARK_MAIN() macro (#332)
* BENCHMARK_MAIN() now reports unrecognised command-line flags (see google/benchmark#320)

* add benchmark::ReportUnrecognizedArguments()

Update BENCHMARK_MAIN() to use ReportUnrecognizedArguments() instead of
having the reporting code directly in the macro.

See issue google/benchmark#320 for reference

* let's stick to american english -- fix type in ReportUnrecognizedArguments()

* make ReportUnrecognizedArguments() print to stderr

* make ReportUnrecognizedArguments() return true if any arguments have been reported (i.e. argc > 1)
2017-01-17 19:28:20 -08:00
jpmag b4fdf6e9df HumanReadableNumber(): Simplify output for simple numbers. Examples: (#291)
* HumanReadableNumber(): Simplify output for simple numbers. Examples:

HumanReadableNumber(    0.0)=      0    ---->         0
HumanReadableNumber(    0.5)=   512m    ---->       0.5
HumanReadableNumber(    0.9)= 921.6m    ---->       0.9
HumanReadableNumber(    1.0)=  1024m    ---->         1
HumanReadableNumber(   1.05)=1075.2m    ---->      1.05
HumanReadableNumber(    1.1)=    1.1    ---->       1.1
HumanReadableNumber(    1.2)=    1.2    ---->       1.2
HumanReadableNumber( 0.0e-1)=      0    ---->         0
HumanReadableNumber( 0.5e-1)=  51.2m    ---->      0.05
HumanReadableNumber( 0.9e-1)= 92.16m    ---->      0.09
HumanReadableNumber( 1.0e-1)= 102.4m    ---->       0.1
HumanReadableNumber(1.05e-1)=107.52m    ---->     0.105
HumanReadableNumber( 1.1e-1)=112.64m    ---->      0.11
HumanReadableNumber( 1.2e-1)=122.88m    ---->      0.12
HumanReadableNumber( 0.0e-3)=      0    ---->         0
HumanReadableNumber( 0.5e-3)=524.288u   ---->   524.288u
HumanReadableNumber( 0.9e-3)=943.718u   ---->   943.718u
HumanReadableNumber( 1.0e-3)=1048.58u   ---->   1048.58u
HumanReadableNumber(1.05e-3)=  1101u    ---->   0.00105
HumanReadableNumber( 1.1e-3)=1.1264m    ---->    0.0011
HumanReadableNumber( 1.2e-3)=1.2288m    ---->    0.0012

* HumanReadableNumber(): change simple printing threshold to 0.01.

* ToExponentAndMantissa(): refactor branch sequence.
2017-01-13 14:19:42 -08:00
Alt 34010beecb Fix librt linking on systems which has it (#331) 2017-01-13 08:41:29 -08:00
BRevzin 4bf28e611b Issue 327 (#328)
Arguments shouldn't be AppendHumanReadable()-ed, they should just be shown as-is.
2016-12-20 11:37:17 -08:00
Pavel Campr e381139474 fix compare script - output formatting - correctly align numbers >9999 (#322)
* fix compare script - output formatting - correctly align numbers >9999

* fix failing test (report.py); fix compare script output formatting (large numbers alignment)
2016-12-09 05:24:31 -07:00
Niklas Rosenstein 56336e70f1 fix argv accessed out of bounds in ParseCommandLineFlags() (#321) 2016-12-06 08:38:03 -08:00
Eric efd4e992a6 Add support for building w/o exceptions (#317) 2016-12-05 09:24:09 -08:00
Eric a3eac442c2 Update the required CMake version to 2.8.12 (#316) 2016-12-05 09:22:46 -08:00
Eric 83ac086fbd Add compare_bench.py documentation. Fixes #309 (#318) 2016-12-02 19:47:27 -07:00
Eric Fiselier a8aa40c596 Fix obvious typo in string formatting 2016-11-19 05:17:52 -07:00
Eric Fiselier 2373382284 Rewrite compare_bench.py argument parsing.
This patch cleans up a number of issues with how compare_bench.py handled
the command line arguments.

* Use the 'argparse' python module instead of hand rolled parsing. This gives
  better usage messages.

* Add diagnostics for certain --benchmark flags that cannot or should not
  be used with compare_bench.py (eg --benchmark_out_format=csv).

* Don't override the user specified --benchmark_out flag if it's provided.

In future I would like the user to be able to capture both benchmark output
files, but this change is big enough for now.

This fixes issue #313.
2016-11-18 15:42:02 -07:00
Dominic Hamon 4f8bfeae47 Report error when no benchmarks match regex. (#308)
Fixes #306
2016-10-28 14:22:22 -07:00
Marek Kurdej 0064c56abd Add tests for reporters (#307)
* Test bytes_per_second and items_per_second.

* Test SetLabel.

* Reformat.

* Make State::error_occurred_ private.

* Fix tests with floats.

* Merge private blocks
2016-10-28 09:13:57 -07:00
Dominic Hamon 8e08aa75d9 Merge branch 'mkurdej-arg-names' 2016-10-26 09:22:18 -07:00
Marek Kurdej 3f23832a09 Allow calling Args and ArgNames in any order. 2016-10-26 09:36:39 +02:00
Marek Kurdej cfee1a54e4 Check argument count in ArgName and ArgNames. 2016-10-26 09:29:28 +02:00
Marek Kurdej c1c01b2cd3 Handle the case when the argument name is an empty string. 2016-10-25 09:45:35 +02:00
Marek Kurdej 17e1c405dd Add ArgName() and ArgNames() methods to name arguments/ranges. 2016-10-24 09:57:40 +02:00