Commit Graph

130 Commits

Author SHA1 Message Date
Mircea Trofin 376ebc2635
Support optional, user-directed collection of performance counters (#1114)
* Support optional, user-directed collection of performance counters

The patch allows an engineer wishing to drill into the root causes
of a regression, for example. Currently, only single threaded runs
are supported. The feature is a build-time opt in, and then a runtime
opt in.

The engineer may run the benchmark executable, passing a list of
performance counter names (using libpfm's naming scheme) at the
command line. The counter values will then be collected and reported
back as UserCounters.

This is different from #240 in that it is a benchmark user opt-in, and
the counter collection is transparent to the benchmark.

Currently, this is only supported on platforms where libpfm is
supported.

libpfm: http://perfmon2.sourceforge.net/

* 'Use' values param in Snapshot when BENCHMARK_OS_WINDOWS

This is to avoid unused parameter warning-as-error

* Added missing include for <vector> in perf_counters.cc

* Moved doc to docs

* Added license blurbs
2021-04-28 09:25:29 +01:00
Dominic Hamon 0882a74c8b
Add bazel status to README 2021-04-19 17:25:59 +01:00
Dominic Hamon b8084e5054
fix minor typo 2021-04-09 12:59:31 +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
Andre Meyering cc9abfc8f1
Fix URL to googletest primer (#1102) 2021-03-08 12:23:24 +03:00
Phoenix Meadowlark 5c43112eb3
Update 'Output Files' section to reflect csv support. (#1095) 2021-02-22 09:55:59 +00:00
Dominic Hamon 2d9bfe1ef8
Include github workflows status in README 2020-09-28 10:54:55 +01: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
Dominic Hamon 5c25ad3acb
Ctest support (#1025)
* ctest is now working

* Update README

* remove commented out lines

* Tweaked docs

Added note to use parallel and cleaned build config notes

* Response to comments

* revert all but the readme

* make error message clearer

* drop --parallel
2020-08-21 16:25:56 +01:00
Adam Badura bb978c06d0
Update build instructions to better use CMake (#1017)
Build instructions needlessly referred to make when CMake offers
a command-line interface to abstract away from the specific build
system.

Furthermore, CMake offers command-line "tool mode" which performs basic
filesystem operations. While the syntax is a bit more verbose than
Linux commands it is platform-independent. Now the commands can be
copy-pasted on both Linux and Windows and will just work.

Finally, the Release build type is included in initial commands. A natural flow
for a new-comer is to read and execute the commands and only then learn
that one has to go back and redo them again this time with proper parameters.
Now instead the parameters are only explained later but present already in the
initial commands.
2020-08-19 11:57:19 +01:00
Paweł Bylica c078337494
Relax CHECK condition in benchmark_runner.cc (#938)
* Add State::error_occurred()

* Relax CHECK condition in benchmark_runner.cc

If the benchmark state contains an error, do not expect any iterations has been run.
This allows using SkipWithError() and return early from the benchmark function.

* README.md: document new possible usage of SkipWithError()
2020-02-21 17:53:25 +03:00
Nick 168604d8f8
[docs] Use `benchmark::IterationCount` rather than `int64_t` in lambda to complexity (#940) 2020-02-18 15:04:45 +03: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
Roman Lebedev 318d07113d
README.md: a few adjustments after #894 2019-12-01 13:42:52 +03:00
Martin Blanchard daf276ff94 Document environment variables options usage (#894)
See https://github.com/google/benchmark/issues/881
2019-12-01 13:40:10 +03:00
Chunsheng Pei b8bce0c7ed fixed the param order in g++ command and fixed the path for -L (#879)
* fixed the param order in g++ command and fixed the path for -L

* reorder the parameters for g++ command
2019-09-27 12:09:23 +01: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
sharpe5 bf4f2ea0bd Addresses issue #634. (#866)
* Update with instructions to build under Visual Studio

Fixes Issue #634.

I spent 3 days trying to build this library under Visual Studio 2017, only to discover on has to link to `Shlwapi.lib`.

Became so frustrated with the docs that I added full build instructions for Visual Studio 2015, 2017 and Intel Comiler 2015 and 2019.

* Update headings
2019-09-16 09:05:05 +01: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
Roman Lebedev 3523f11d36
Update README.md: fix MS VS version requirement
VS2013 is unsupported since https://github.com/google/benchmark/pull/691 / eb8cbec077
but i forgot to update docs.
References:
* https://github.com/google/benchmark/issues/689
* https://github.com/google/benchmark/pull/691
* https://github.com/google/googletest/pull/1815
* https://github.com/google/benchmark/issues/853
* https://github.com/google/benchmark/pull/854
2019-08-21 15:14:27 +03:00
Roman Lebedev 7d97a057e1
Custom user counters: add invert modifier. (#850)
While current counters can e.g. answer the question
"how many items is processed per second", it is impossible to get
it to tell "how many seconds it takes to process a single item".

The solution is to add a yet another modifier `kInvert`,
that is *always* considered last, which simply inverts the answer.

Fixes #781, #830, #848.
2019-08-12 17:47:46 +03:00
LesnyRumcajs 140fc22ab2 Corrected the installation procedure (#849)
* Corrected the installation procedure

Now it can be put into a script.

* Updated the file tree

Necessary after installation instruction change
2019-08-06 13:36:36 +03:00
Xinye Tao 140db8a229 fix typo in README (#844) 2019-07-30 09:03:15 +03:00
blackliner 66482d538d README.md: corrected cmake commands (#846)
* corrected cmake commands

* Update README.md
2019-07-29 23:59:25 +03:00
Boris Dergachov ff7e2d45a5 README.md: Spelling fix (#845) 2019-07-29 23:59:06 +03:00
Jason Cooke df4f9fe362 docs: fix typo (#837) 2019-07-17 10:01:07 +03:00
Dominic Hamon 13b8bdc2b5
Bump required cmake version from 2.x to 3.x (#801) 2019-05-01 09:06:12 +01:00
astee 05d8c1c5d0 Improve README (#804)
* Update and organize README

* Update AUTHORS and CONTRIBUTORS

Fixes #803.
2019-04-25 14:48:56 +03:00
Bryan Lunt 7a1c370283 Add process_time for better OpenMP and user-managed thread timing
* Google Benchmark now works with OpenMP and other user-managed threading.
2019-04-09 13:01:33 +01:00
Roman Lebedev b8ca0c4217
README.md: mention that fixture has SetUp() / TearDown() 2019-02-04 16:26:51 +03:00
Roman Lebedev 57bf879d49
README.md: document State::{Pause,Resume}Timing()
As pointed out in IRC, these are not documented.
2018-12-14 01:20:01 +03:00
Roman Lebedev 19f7d5c2bc
README.md: complexity lambda takes int64_t arg. Fixes #719 2018-11-29 01:23:25 +03:00
Roman Lebedev c9311a44e1
README.md: BM_Sequential(): the return type is 'void'
Used that example as a snippet, and it took a moment to notice
what needed to be changed to make it compile..
2018-11-26 15:39:36 +03:00
Roman Lebedev c614dfc0d4
*Display* aggregates only. (#665)
There is a flag 
d9cab612e4/src/benchmark.cc (L75-L78)
and a call
d9cab612e4/include/benchmark/benchmark.h (L837-L840)
But that affects everything, every reporter, destination:
d9cab612e4/src/benchmark.cc (L316)


It would be quite useful to have an ability to be more picky.


More specifically, i would like to be able to only see the aggregates in the on-screen output,
but for the file output to still contain everything. The former is useful in case of a lot of repetition
(or even more so if every iteration is reported separately), while the former is **great** for tooling.

Fixes https://github.com/google/benchmark/issues/664
2018-09-12 16:26:17 +03:00
Roman Lebedev caa2fcb19c
Counter(): add 'one thousand' param. (#657)
* Counter(): add 'one thousand' param.

Needed for https://github.com/google/benchmark/pull/654

Custom user counters are quite custom. It is not guaranteed
that the user *always* expects for these to have 1k == 1000.
If the counter represents bytes/memory/etc, 1k should be 1024.

Some bikeshedding points:
1. Is this sufficient, or do we really want to go full on
   into custom types with names?
   I think just the '1000' is sufficient for now.
2. Should there be a helper benchmark::Counter::Counter{1000,1024}()
   static 'constructor' functions, since these two, by far,
   will be the most used?
3. In the future, we should be somehow encoding this info into JSON.

* Counter(): use std::pair<> to represent 'one thousand'

* Counter(): just use a new enum with two values 1000 vs 1024.

Simpler is better. If someone comes up with a real reason
to need something more advanced, it can be added later on.

* Counter: just store the 1000 or 1024 in the One_K values directly

* Counter: s/One_K/OneK/
2018-08-29 21:11:06 +03:00
Roman Lebedev 94c4d6d5c6 [Tools] Drop compare_bench.py, compare.py is to be used, add U-test docs. (#645)
As discussed in IRC, time to deduplicate.
2018-08-13 07:42:35 -07:00
Dominic Hamon d939634b8c
README improvements (#648)
* Clarifications and cleaning of the core documentation.
2018-07-26 14:29:33 +01:00
Yoshinari Takaoka 847c006902 fixed Google Test (Primer) Documentation link (#628) 2018-06-28 10:25:54 +01:00
Dominic Hamon ec0f69c28e
Update README.md 2018-05-29 10:36:54 +01:00
Alex Strelnikov e776aa0275 Add benchmark_main target. (#601)
* Add benchmark_main library with support for Bazel.

* fix newline at end of file

* Add CMake support for benchmark_main.

* Mention optionally using benchmark_main in README.
2018-05-25 11:18:58 +01:00
mattreecebentley d7aed73677 Corrections, additions to initial doc (#600)
* Correct/clarify build/install instructions

GTest is google test, don't obsfucate needlessly for newcomers.
Adding google test into installation guide helps newcomers.
Third option under this  line: "Note that Google Benchmark requires Google Test to build and run the tests. This
dependency can be provided three ways:"
Was not true (did not occur). If there is a further option that needs to be specified in order for that functionality to work it needs to be specified.

* Add prerequisite knowledge section

A lot of assumptions are made about the reader in the documentation. This is unfortunate.

* Removal of abbreviations for google test
2018-05-24 10:50:35 +01:00
Alex Strelnikov 62a9d756ea Update bazel WORKSPACE and BUILD files to work better on Windows. (#581)
Note, bazel only supports MSVC on Windows, and not MinGW, so
linking against shlwapi.lib only needs to follow MSVC conventions.

git_repository() did not work in local testing, so is swapped for
http_archive(). The latter is also documented as the preferred way
to depend on an external library in bazel.
2018-05-02 11:23:18 +01:00
Eric 7b03df7ff7
Add tests to verify assembler output -- Fix DoNotOptimize. (#530)
* Add tests to verify assembler output -- Fix DoNotOptimize.

For things like `DoNotOptimize`, `ClobberMemory`, and even `KeepRunning()`,
it is important exactly what assembly they generate. However, we currently
have no way to test this. Instead it must be manually validated every
time a change occurs -- including a change in compiler version.

This patch attempts to introduce a way to test the assembled output automatically.
It's mirrors how LLVM verifies compiler output, and it uses LLVM FileCheck to run
the tests in a similar way.

The tests function by generating the assembly for a test in CMake, and then
using FileCheck to verify the // CHECK lines in the source file are found
in the generated assembly.

Currently, the tests only run on 64-bit x86 systems under GCC and Clang,
and when FileCheck is found on the system.

Additionally, this patch tries to improve the code gen from DoNotOptimize.
This should probably be a separate change, but I needed something to test.

* Disable assembly tests on Bazel for now

* Link FIXME to github issue

* Fix Tests on OS X

* fix strip_asm.py to work on both Linux and OS X like targets
2018-03-23 16:10:47 -06:00
alekseyshl 47df49e573 Add Solaris support (#539)
* Add Solaris support

Define BENCHMARK_OS_SOLARIS for Solaris.

Platform specific implementations added:
* number of CPUs detection
* CPU cycles per second detection
* Thread CPU usage
* Process CPU usage

* Remove the special case for per process CPU time for Solaris, it's the same as the default.
2018-03-02 03:53:58 -08:00
Jonathan Wakely e9a49be7f1 Update note about linking with pthreads (#536) 2018-02-21 08:42:16 -08:00
Jonathan Wakely 19048b7b65 Fix typo in README.md (#535) 2018-02-21 08:41:52 -08:00
Winston Du 052421c823 Updated documentation. (#503)
For people who get this library via CMake's AddExternalProject like me.
Would like a long term tutorial from someone who really understands CMake on how to actually link an externalproject's dependencies to another added external project.
2018-01-04 17:13:34 -07:00
Dominic Hamon e4ccad7c4a
Update README.md 2017-12-14 09:40:26 -08:00
Eric 7db02be244
Add support for GTest based unit tests. (#485)
* Add support for GTest based unit tests.

As Dominic and I have previously discussed, there is some
need/desire to improve the testing situation in Google Benchmark.

One step to fixing this problem is to make it easier to write
unit tests by adding support for GTest, which is what this patch does.

By default it looks for an installed version of GTest. However the
user can specify -DBENCHMARK_BUILD_EXTERNAL_GTEST=ON to instead
download, build, and use copy of gtest from source. This is
quite useful when Benchmark is being built in non-standard configurations,
such as against libc++ or in 32 bit mode.
2017-12-13 16:26:47 -07:00
Eric Fiselier de725e5a7c Document new 'v2' branch meant for unstable development.
This patch documents the newly added v2 branch, which will
be used to stage, test, and receive feedback on upcoming
features, most of which will be breaking changes which can't
be directly applied to master.
2017-12-13 14:51:56 -07:00