Commit graph

291 commits

Author SHA1 Message Date
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
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
Dominic Hamon 4f8bfeae47 Report error when no benchmarks match regex. (#308)
Fixes #306
2016-10-28 14:22:22 -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
Marek Kurdej 5aa3855627 Fix displayed time unit in mean and standard deviation. 2016-10-21 14:33:23 +02:00
Eric Fiselier 57a22c69b3 Fix typo in timer.cc that caused negative CPU times on OS X. Fixes #293 2016-10-08 02:12:40 -06:00
Eric Fiselier 721c9224b9 Fix getting the CPU frequency on OS X 2016-10-08 01:38:09 -06:00
Eric Fiselier 03c4485d84 Fix #295. Remove use of BSD extensions for comparing strings 2016-10-07 22:54:06 -06:00
Eric Fiselier 36a251ab3e Fix #300. Emit RMS as a float not a percentage in JSON 2016-10-07 22:26:01 -06:00
Dominic Hamon 332f677b8b Apply clang-format to all headers and source (#303) 2016-10-07 11:35:03 -07:00
Eric Fiselier 2aca242bf6 Fix various uninitialized members 2016-09-28 18:21:36 -06:00
Alt 6cadcf7f14 Fix working on mac clock_gettime (#292)
* fix working on mac clock_gettime

* Comment fixme
2016-09-26 15:48:25 -07:00
Nicholas Hutchinson 917b86e615 Auto-detect whether Benchmark should produce colorized output (#126)
* Auto-detect whether to produce colorized output

Rename --color_print to --benchmark_color for consistency with the other
flags (and Google Test). Old flag name is kept around for compatibility.

The --benchmark_color/--color_print flag takes a third option, "auto",
which is the new default. In this mode, we attempt to auto-detect
whether to produce colorized output. (The logic for deciding whether to
use colorized output was lifted from GTest:
<https://github.com/google/googletest/blob/master/googletest/src/gtest.cc#L2925>.)

* Update CONTRIBUTORS, AUTHORS
2016-09-15 15:10:35 -06:00
Nicholas Hutchinson b826143ac2 Flush reporters' output streams after writing a benchmark run (#288)
If a reporter's output stream isn't line-buffered (e.g. it's not writing
to a terminal) then it can be some time before a write to it becomes
visible.

This is problematic if, say, you're wanting to use tail -f to view the
file written to via --benchmark_out. Or if the application crashes,
leaving you with no results.

Addressed by flushing the reporters' output streams whenever we invoke
methods that may write to them.
2016-09-11 15:36:14 -06:00
Eric c6f3f0eb9c Cleanup RunBenchmark code. (#289)
* Cleanup the code for generating and running benchmarks

* Rework calculation of real/manual time

* Add back TSAN builder
2016-09-06 02:28:35 -06:00
Eric d038472c18 Refactor benchmark.cc into benchmark_register.cc and benchmark.cc (#287)
* 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
2016-09-05 15:48:40 -06:00
Ronny 72be9523bb Add Benchmark::ThreadRange() version with increment instead of multiply (#283)
* add additive thread range

* add test
2016-09-03 13:56:46 -06:00
Eric Fiselier f261c68074 Try and add MSVC NORETURN attribute again 2016-09-03 00:13:20 -06:00
Eric Fiselier 5224b63c35 Fix BENCHMARK_NORETURN on MSVC 2016-09-02 23:54:58 -06:00
Eric cba945e37d Make PauseTiming() and ResumeTiming() per thread. (#286)
* 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
2016-09-02 21:34:34 -06:00
biojppm 83561f0580 CMake: add headers to the list of source files. (#284)
cmake does not require this, but IDEs such as VisualStudio or QtCreator
need this to add the headers to the generated project.
2016-08-31 15:28:43 -07:00
Eric df7bd92afd Add warning for large benchmark families (#279)
* Add warning for large benchmark families

* reflow comment
2016-08-29 12:43:55 -06:00
Eric 6e25917001 Add -DBENCHMARK_USE_LIBCXX:BOOL=<value> option. (#280)
* Add BENCHMARK_USE_LIBCXX option.

* Add comments

* re-add zero null pointer warning
2016-08-29 12:43:30 -06:00
Eric Fiselier 2e0796e148 Cleanup and optimize Range generation. 2016-08-28 23:15:55 -06:00
Eric Fiselier db1af86d16 Fix out-of-bounds std::vector access.
In the `Ranges(...)` generation code a "control" vector which stores
the current index for each range passed to `Ranges`. Previously this vector
was incorrectly initialized to the size of the subranges not the number
of subranges.

Additionally this patch suppresses unused warnings generated by
`stream_init_anchor`.
2016-08-28 23:07:38 -06:00
Eric Fiselier cbcd7b656e Fix std::cout/std::cerr static initialization order fiasco.
The benchmark library internals write to std::cout/std::cerr during program
startup. This can cause segfaults when the user doesn't include <iostream> in
the benchmark (which init's the streams). This patch fixes this by emitting
a dynamic initializer in every TU which initializes the streams.
2016-08-28 22:48:48 -06:00
Eric a11fb69c89 Add --benchmark_report_aggregates_only={true|false} flag for better summary output. (#267) 2016-08-10 18:20:54 -06:00
Eric Fiselier 95dee3c699 Work around bogus GCC warning 2016-08-08 02:22:49 -06:00
Eric Fiselier c04f703ab4 Fix signed integer overflow UB in complexity computations.
Previously the FittingCurve functions for n^2 and n^3 did the calculation
using int types. This can overflow and cause UB. This patch changes the
calculations to use std::pow to prevent this.

Also re-enable VC 2013 appveyor bot since I *hope* this is what was causing
the failures.
2016-08-07 17:33:18 -06:00
Marcin Kolny dfe0260754 Support multiple ranges in the benchmark (#257)
* Support multiple ranges in the benchmark

google-benchmark library allows to provide up to two ranges to the
benchmark method (range_x and range_y). However, in many cases it's not
sufficient. The patch introduces multi-range features, so user can easily
define multiple ranges by passing a vector of integers, and access values
through the method range(i).

* Remove redundant API

Functions State::range_x() and State::range_y() have been removed. They should
be replaced by State::range(0) and State::range(1).
Functions Benchmark::ArgPair() and Benchmark::RangePair() have been removed.
They should be replaced by Benchmark::Args() and Benchmark::Ranges().
2016-08-04 12:30:14 -07:00
Eric Fiselier 44128d87d2 Add --benchmark_out=<filename> and --benchmark_out_format=<format> options.
These options allow you to write the output of a benchmark to the specified
file and with the specified format. The goal of this change is to help support
tooling.
2016-08-02 15:12:43 -06:00
Vadym f68e64c60a add support for step in DenseRange() (#260) 2016-07-25 21:13:09 +02:00
Eric Fiselier a2ca94dd10 Fix missing SYSTEM_INFO initializers 2016-07-23 16:22:13 -06:00
Sven ebd37b191c set cpuinfo_num_cpus on Windows (#254) 2016-07-13 13:00:32 -07:00
Elliott Hughes b805b7c6e0 Add missing volatiles to 32-bit ARM cycleclock assembler. (#253)
Without these, clang reorders these instructions as if they were
regular loads/stores which causes SIGILL from the kernel because
it performs all the loads before it starts testing the values.
2016-07-12 12:40:09 -07:00
Ismael 885ca41cf8 added check for SetComplexityN (#248) 2016-06-27 11:26:23 -07:00
Ismael a0783fd7f6 fix 244 (#247) 2016-06-27 11:25:43 -07:00
Ismael 3fdd76bd14 fix issue 235 (#236) 2016-06-03 09:33:17 -07:00
Dominic Hamon e498143168 fix warning on loss of integer precision 2016-06-02 14:37:14 -07:00
Dominic Hamon 51c23a9115 Merge branch 'added_lambdas' of git://github.com/ismaelJimenez/benchmark into ismaelJimenez-added_lambdas 2016-06-02 14:33:14 -07:00
Ismael 1a633969b3 changed BigO logic order 2016-06-02 22:23:39 +02:00