Commit Graph

61 Commits

Author SHA1 Message Date
Marcel Jacobse f23fedbbf8
Fix examples in user guide using deprecated `DoNotOptimize`-API (#1568)
* Update AUTHORS/CONTRIBUTORS

* Fix examples with deprecated DoNotOptimize API

The const-reference API to DoNotOptimize was deprecated with #1493. Some
examples in the user guide are using exactly that deprecated interface.
This fixes that by passing non-const lvalues instead. Fixes #1566
2023-03-07 14:47:03 +00:00
Henrique Bucher 27c1d8ace9
Implement unlimited number of performance counters (#1552)
* Implement unlimited number of performance counters

Linux performance counters will limit the number of hardware
counters per reading group. For that reason the implementation of
PerfCounters is limited to 3. However if only software counters
are added, there is no reason to limit the counters. For hardware
counters, we create multiple groups and store a vector or leaders
in the PerfCounters object. When reading, there is an extra time
waste by iterating through all the group leaders. However this
should be the same performance as with today. Reading is done by
groups and it had to be heavily adjusted with the logic being
moved to PerfCounterValues. I created a test for x86-64 and took
care of filtering out the events in case it runs in a platform
that does not support those counters - the test will not fail. The
current tests were already failing (ReOpenExistingCounters,
CreateExistingMeasurements and MultiThreaded) on the main branch
and they continue to fail after this implementation - I did not
fix those not to conflate all here.

* Moved the PerfCounterValues::Read() implementation from header to body.

* Added missing implementation of PerfCounters::IsCounterSupported when HAVE_LIBPFM is not defined.

* Changed comments to reflect the implementation

* Removed arg name so it does not generate an error when HAVE_LIBPBM is not defined.

* Made loop counter a const reference for clang-tidy

* Added missig BENCHMARK_EXPORT to PerfCounterValues
2023-03-01 15:30:41 +00:00
Raghu Raja 398a8ac2e8
[bazel] Build libpfm as a dependency to allow collection of perf counters (#1408)
* Build libpfm as a dependency to allow collection of perf counters

This commit builds libpfm using rules_foreign_cc and lets the default
build of the benchmark library support perf counter collection without
needing additional work from users.

Tested with a custom target:

```
bazel run \
        --override_repository=com_github_google_benchmark=/home/raghu/benchmark \
        -c opt :test-bench -- "--benchmark_perf_counters=INSTRUCTIONS,CYCLES"
Using profile: local

<snip>

----------------------------------------------------------------------
Benchmark            Time             CPU   Iterations UserCounters...
----------------------------------------------------------------------
BM_Test      0.279 ns        0.279 ns   1000000000 CYCLES=1.00888 INSTRUCTIONS=2

```

Signed-off-by: Raghu Raja <raghu@enfabrica.net>

* Adding myself to the CONTRIBUTORS file per CLA guidance

Enfabrica has already signed a corporate CLA.

Signed-off-by: Raghu Raja <raghu@enfabrica.net>

Signed-off-by: Raghu Raja <raghu@enfabrica.net>
2022-10-31 11:03:59 +00:00
rorth 12e0d70a43
Fix Solaris compilation (#1499) (#1500)
This patch fixes compilation on Solaris, addressing the problems reported
in Issue #1499:

* Provide `HOST_NAME_MAX` definition.
* Match `sysconf(3C)` return type.
* Avoid `-Wcast-qual` warnings with `libkstat(3KSTAT)` functions.
* Avoid clash with `<floatingpoint.h>` `single` typedef.
2022-10-06 09:18:55 +01:00
Cezary Skrzyński 4efcc47461
Suppress nvcc `offsetof` warning (#1429)
* Suppress nvcc offsetof warning

* Update AUTHORS and CONTRIBUTORS
2022-07-15 12:18:45 +01:00
Bátor Tallér d08e7b6056
Allow setting the default time unit globally (#1337)
* Add option to set the default time unit globally

This commit introduces the `--benchmark_time_unit={ns|us|ms|s}` command line argument. The argument only affects benchmarks where the time unit is not set explicitly.

* Update AUTHORS and CONTRIBUTORS

* Test `SetDefaultTimeUnit`

* clang format

* Use `GetDefaultTimeUnit()` for initializing `TimeUnit` variables

* Review fixes

* Export functions

* Add comment
2022-03-04 11:07:01 +00:00
staffantj 6dfe7afbc3
Address c4267 warning on MSVC (#1315)
* Fix #1159 Harmonize the types between the loop counter and the vector of indices

The loop counter is a size_t, but they're stored in a vector-of-int leading to
potential overflow warnings. In order to avoid accidental run-time overflow
this change modifies the vector type, rather than the loop counter.

* Fix up line endings

* Update AUTHORS

Add Staffan Tjernstrom <staffantj@gmail.com>

Co-authored-by: Staffan Tjernstrom <staffantj@users.noreply.github.com>
2022-01-10 14:43:29 +00:00
dominc8 680d3fdbb5
Add clang-tidy check (#1290)
* Add clang-tidy.yml and .clang-tidy

* Add mention to authors/contributors

* Temp fix 2 clang-tidy issues

* Enable clang-tidy on pull requests

* Exclude gtest source files from clang-tidy
2021-11-25 15:47:44 +00:00
Donald Aingworth a07f6d1789
Googletest renamed master to main today. (#1285)
Co-authored-by: Donald Aingworth <donald@midpointmarkets.org>
2021-11-17 09:45:03 +00:00
Norman Heino 6f094ba13e
Fix perf counter argument parsing (#1160)
* Fix argument order in StrSplit

* Update AUTHORS, CONTRIBUTORS
2021-06-01 15:50:42 +01:00
Tobias Schmidt 5e387e7d33
Implement custom benchmark name (#1107)
* Implement custom benchmark name

The benchmark's name can be changed using the Name() function
which internally uses SetName().

* Update AUTHORS and CONTRIBUTORS

* Describe new feature in README

* Move new name function up

Fixes #1106
2021-03-30 16:43:03 +03:00
Min-Yih Hsu ffe1342eb2
Add CycleTimer implementation for M68K architecture (#1050)
As per discussions in here [1], LLVM is going to get backend support on
Motorola 68000 series CPUs (a.k.a M68K or M680x0). So it's necessary to
add CycleTimer implementation here, which is simply using `gettimeofday`
same as MIPS. This fixes #1049

[1] https://reviews.llvm.org/D88389
2020-09-29 09:35:18 +03:00
Christian Wassermann 4857962394
Add CartesianProduct with associated test (#1029)
* Add CartesianProduct with associated test

* Use CartesianProduct in Ranges to avoid code duplication
* Add new cartesian_product_test to CMakeLists.txt
* Update AUTHORS & CONTRIBUTORS

* Rename CartesianProduct to ArgsProduct

* Rename test & fixture accordingly
* Add example for ArgsProduct to README
2020-08-25 13:47:44 +01: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
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
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
Eric Backus 32a1e39720 Bugfix/wsl selftest fixes. Fixes #839 (#843)
* Update AUTHORS and CONTRIBUTORS

* Fix WSL self-test failures

Some of the benchmark self-tests expect and check for a particular
output format from the benchmark library. The numerical values must
not be infinity or not-a-number, or the test will report an error.
Some of the values are computed bytes-per-second or items-per-second
values, so these require that the measured CPU time for the test to be
non-zero. But the loop that is being measured was empty, so the
measured CPU time for the loop was extremely small. On systems like
Windows Subsystem for Linux (WSL) the timer doesn't have enough
resolution to measure this, so the measured CPU time was zero.

This fix just makes sure that these tests have something within the
timing loop, so that the benchmark library will not decide that the
loop takes zero CPU time. This makes these tests more robust, and in
particular makes them pass on WSL.
2019-07-27 19:02:31 +03:00
astee 05d8c1c5d0 Improve README (#804)
* Update and organize README

* Update AUTHORS and CONTRIBUTORS

Fixes #803.
2019-04-25 14:48:56 +03:00
Daniel Harvey f6e96861a3 BENCHMARK_CAPTURE() and Complexity() - naming problem (#761)
Created BenchmarkName class which holds the full benchmark
name and allows specifying and retrieving different components
of the name (e.g. ARGS, THREADS etc.)

Fixes #730.
2019-03-17 16:38:51 +03:00
Andriy Berestovskyy 4b9f43e2c4 Fix header lines length (#752)
Commit 17a012d7 added a newline to the str, so the line built from
str.length() is one character longer than it should be.
2019-01-13 17:26:49 +03:00
Ori Livneh e1150acab9 Add Ori Livneh to AUTHORS and CONTRIBUTORS 2018-07-09 10:52:28 -04:00
Federico Ficarelli 1f35fa4aa7 Update AUTHORS and CONTRIBUTORS (#632)
Adding myself to AUTHORS and CONTRIBUTORS according to guidelines.
2018-07-09 12:47:16 +01:00
Deniz Evrenci 6d74c0625b split_list is not defined for assembly tests (#595)
* Update AUTHORS and CONTRIBUTORS

* split_list is not defined for assembly tests
2018-05-14 15:02:49 +01:00
jmillikin-stripe a9beffda0b Add support for building with Bazel. (#533)
* Add myself to CONTRIBUTORS under the corp CLA for Stripe, Inc.

* Add support for building with Bazel.

Limitations compared to existing CMake rules:
* Defaults to using C++11 `<regex>`, with an override via Bazel flag
  `--define` of `google_benchmark.have_regex`. The TravisCI config sets
  the regex implementation to `posix` because it uses ancient compilers.
* Debug vs Opt mode can't be set per test. TravisCI runs all the tests
  in debug mode to satisfy `diagnostics_test`, which depends on `CHECK`
  being live.

* Set Bazel workspace name so other repos can refer to it by stable name.

This is recommended by the Bazel style guide to avoid each dependent
workspace defining its own name for the dependency.
2018-03-08 12:48:46 +00:00
Robert Guo ff2c255af5 Use STCK to get the CPU clock on s390x (#540) 2018-03-02 03:22:03 -08:00
Kishan Kumar eae42212ce Added the installation guide for Ubuntu (#489)
* Initial CLA Requirement

* Added Installation steps to the Readme.md

* Fixed error in running benchmark of Installation

* Remove unwanted commands

Removed the lengthy install procedure with suggested install mechanism
2017-11-29 09:36:19 -08:00
Steinar H. Gunderson 0c3ec998c4 Add a pkg-config file, for the benefit of projects not using CMake. (#480) 2017-11-15 11:51:22 -08:00
Roman Lebedev 336bb8db98 Update AUTHORS/CONTRIBUTORS (#471)
As requested, in a pr form :)
2017-11-03 10:00:29 -07:00
Raúl Marín cacd321808 Avoid implicit float to double conversion (#457)
Triggered by -Werror=double-promotion
2017-10-13 09:17:02 -07:00
Dominic Hamon a96ff121b3 Alphabets are hard. AUTHORS version.
#448
2017-09-27 11:53:16 -07:00
Dominic Hamon 8792dff1c9 Remove myself from AUTHORS
Covered by Google Inc here and i'm in CONTRIBUTORS
2017-09-27 20:01:49 +02:00
Dominic Hamon 84a54ae9f4 Organize AUTHORS
Part of #448
2017-09-27 20:00:12 +02:00
Jern-Kuan Leong 710c2b89d8 Fix #403 HAVE_${VAR} not passed to makefile (#404)
Add definition of ${VAR} to makefiles if specified as part of cmake
parameter.
2017-06-16 14:46:11 -07:00
Yixuan Qiu f3b3dd99be Use the sample version of standard deviation (#383)
* remove unnecessary weights

* use sample standard deviation

* add contributor information

* remove redundant code

* initialize variable to eliminate compiler warning
2017-06-05 10:32:15 -07: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
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
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
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
Eric Fiselier 1b57a2ad05 Add myself to AUTHORS.
This is secretly just a test commit to get appveyor to run again.
2016-08-07 15:19:20 -06:00
Albert Pretorius 74e82e822f Force DoNotOptimize operand to memory for both gcc and clang 2016-05-26 07:43:07 +01:00
Ismael 290bd60289 Refactor for pull request 2016-05-21 11:51:42 +02:00
Jussi Knuuttila e253a28402 Manual timing support. 2016-05-05 23:24:13 +03:00
Dominik Czarnota d2917bcded Fixes #165: CustomArguments ret type in README
* adds myself to AUTHORS/CONTRIBUTORS
2015-11-30 16:15:00 +01:00
ryobg 13a67d20e6 Add myself to AUTHORS and CONTRIBUTORS as requested wrt Fix #159. 2015-11-06 20:10:50 +02:00
Zbigniew Skowron cd2e633fe5 Fix get_git_version to use GIT_EXECUTABLE.
get_git_version CMake function uses 'git' command directly, instead of
GIT_EXECUTABLE variable. This causes CMake errors while generating
project files in environments, where 'git' command is not present
in PATH.
2015-10-18 02:13:37 +02:00
Tobias Ulvgard c06da04bcf Adds Dirac Research and me as Author and Contributor 2015-10-07 17:28:00 +02:00
Kaito Udagawa f72d24942a Add Kaito Udagawa to AUTHORS and CONTRIBUTORS 2015-06-16 22:45:57 +09:00
Evgeny Safronov 1bc73789e4 Update AUTHORS and CONTRIBUTORS. 2014-11-14 23:39:38 +04:00
zjx20 b6e5977132 Update AUTHORS 2014-10-05 16:12:31 +08:00