Commit graph

580 commits

Author SHA1 Message Date
Bensuperpc 329fb06d99
Fix error with Fix Werror=old-style-cast (#1272)
* Fix Werror=old-style-cast

Signed-off-by: Bensuperpc <bensuperpc@gmail.com>

* Fix Werror=old-style-cast

Signed-off-by: Bensuperpc <bensuperpc@gmail.com>

* Fix Werror=old-style-cast

Signed-off-by: Bensuperpc <bensuperpc@gmail.com>

* Fix typo

Signed-off-by: Bensuperpc <bensuperpc@gmail.com>

* Fix build error with MacOS

Signed-off-by: Bensuperpc <bensuperpc@gmail.com>

* Revert "Fix build error with MacOS"

This reverts commit cee213bb95.
2021-11-04 12:09:10 +00:00
Vy Nguyen 4f31803ebb
Fix un-initted error in test and fix change the API previously proposed to use std::string instead of raw char* (#1266)
* Fix un-initted error in test.

Found by -Werror,-Wsometimes-uninitialized

* Update spec_arg_test.cc

* additional change:
- Change the API on GetBenchmarkFilter and the `spec` to std::string because google C++ styleguide internally kind of discouraged  using raw const char*
2021-10-29 11:48:56 +01:00
Vy Nguyen 4f47ed2c9a
[RFC] Adding API for setting/getting benchmark_filter flag? (#1254)
* [RFC] Adding API for setting/getting benchmark_filter flag?

This PR is more of a Request-for-comment - open to other ideas/suggestions as well.

Details:
This flag has different implementations(absl vs benchmark) and since the proposal to add absl as a dependency was rejected, it would be nice to have a reliable (and less hacky) way to access this flag internally.
(Actually, reading it isn't much a problem but setting it is).

Internally, we have a sizeable number users to use absl::SetFlags to set this flag. This will not work with benchmark-flags.

Another motivation is that not all users use the command line flag. Some prefer to programmatically set this value.

* fixed build errors

* fix lints again

* per discussion: add additional RunSpecifiedBenchmarks instead.

* add tests

* fix up tests

* clarify comment

* fix stray : in test

* more assertion in test

* add test file to test/CMakeLists.txt

* more test

* make test ISO C++ compliant

* fix up BUILD file to pass the flag
2021-10-27 08:52:57 +01:00
Vitaly Zaitsev 365670e432
Added Doxygen support. (#1228)
Signed-off-by: Vitaly Zaitsev <vitaly@easycoding.org>
2021-10-25 12:32:33 +01:00
Byoungchan Lee 80d70ddd94
Fix -Wdeprecated-declarations warning once more. (#1256)
In #1238, one of MemoryManager's Stop methods was marked as deprecated
and this method is used in the same header. This change generated
-Wdeprecated-declarations warning on every file that includes
"benchmark.h". Use gcc's diagnostics to fix this warning.
2021-10-21 10:10:38 +01:00
Sergiu Deitsch 1be88c0683 cmake: allow to use package config from build directory 2021-10-19 11:11:11 +02:00
Sergiu Deitsch eb9100bf41 cmake: make package config relocatable 2021-10-19 11:05:29 +02:00
Vy Nguyen 7fad964a94
Introduce additional memory metrics (#1238)
- added total_allocs and net_allocs
  - updated reporter code to report these, if available.
2021-10-18 16:29:35 +01:00
Byoungchan Lee f730846b0a
Fix -Wdeprecated-declarations warning triggered by clang-cl. (#1245)
WebRTC uses Google Benchmarks as a dependency and uses Chromium's build
infrastructure. Chromium is compiled using clang-cl on Windows, and the
-Wdeprecated-declarations warning is triggered. Because clang-cl accepts
gcc's diagnostic prama and defines the __clang__ macro,
using it can solve this issue.

Bug: webrtc:13280
2021-10-18 11:31:51 +01:00
Sergiu Deitsch 59bbc7fd9d
cmake: eliminate redundant target_include_directories (#1242) 2021-10-17 15:07:19 +03:00
Vitaly Zaitsev 1bd8098d3d
Optimized docs installation (#1225)
* Use GNUInstallDirs to install docs.

Signed-off-by: Vitaly Zaitsev <vitaly@easycoding.org>

* Added an option to disable docs installation.

Signed-off-by: Vitaly Zaitsev <vitaly@easycoding.org>
2021-09-08 18:40:25 +01:00
Roman Lebedev 4f8070590c
COnsole reporter: if statistic produces percents, format it as such (#1221) 2021-09-06 11:33:27 +03:00
Roman Lebedev 45b194e4d4
Introduce Coefficient of variation aggregate (#1220)
* Introduce Coefficient of variation aggregate

I believe, it is much more useful / use to understand,
because it is already normalized by the mean,
so it is not affected by the duration of the benchmark,
unlike the standard deviation.

Example of real-world output:
```
raw.pixls.us-unique/GoPro/HERO6 Black$ ~/rawspeed/build-old/src/utilities/rsbench/rsbench GOPR9172.GPR --benchmark_repetitions=27 --benchmark_display_aggregates_only=true --benchmark_counters_tabular=true
2021-09-03T18:05:56+03:00
Running /home/lebedevri/rawspeed/build-old/src/utilities/rsbench/rsbench
Run on (32 X 3596.16 MHz CPU s)
CPU Caches:
  L1 Data 32 KiB (x16)
  L1 Instruction 32 KiB (x16)
  L2 Unified 512 KiB (x16)
  L3 Unified 32768 KiB (x2)
Load Average: 7.00, 2.99, 1.85
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Benchmark                                                      Time             CPU   Iterations  CPUTime,s CPUTime/WallTime     Pixels Pixels/CPUTime Pixels/WallTime Raws/CPUTime Raws/WallTime WallTime,s
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
GOPR9172.GPR/threads:32/process_time/real_time_mean         11.1 ms          353 ms           27   0.353122          31.9473        12M       33.9879M        1085.84M      2.83232       90.4864  0.0110535
GOPR9172.GPR/threads:32/process_time/real_time_median       11.0 ms          352 ms           27   0.351696          31.9599        12M       34.1203M        1090.11M      2.84336       90.8425  0.0110081
GOPR9172.GPR/threads:32/process_time/real_time_stddev      0.159 ms         4.60 ms           27   4.59539m        0.0462064          0       426.371k        14.9631M    0.0355309       1.24692   158.944u
GOPR9172.GPR/threads:32/process_time/real_time_cv           1.44 %          1.30 %            27  0.0130136         1.44633m          0      0.0125448       0.0137802    0.0125448     0.0137802  0.0143795
```

Fixes https://github.com/google/benchmark/issues/1146

* Be consistent, it's CV, not 'rel std dev'
2021-09-03 18:44:10 +01:00
Roman Lebedev 12dc5eeafc
Statistics: add support for percentage unit in addition to time (#1219)
* Statistics: add support for percentage unit in addition to time

I think, `stddev` statistic is useful, but confusing.

What does it mean if `stddev` of `1ms` is reported?
Is that good or bad? If the `median` is `1s`,
then that means that the measurements are pretty noise-less.

And what about `stddev` of `100ms` is reported?
If the `median` is `1s` - awful, if the `median` is `10s` - good.

And hurray, there is just the statistic that we need:
https://en.wikipedia.org/wiki/Coefficient_of_variation

But, naturally, that produces a value in percents,
but the statistics are currently hardcoded to produce time.

So this refactors thinkgs a bit, and allows a percentage unit for statistics.

I'm not sure whether or not `benchmark` would be okay
with adding this `RSD` statistic by default,
but regales, that is a separate patch.

Refs. https://github.com/google/benchmark/issues/1146

* Address review notes
2021-09-03 15:36:56 +01:00
Dominic Hamon 2b093325e1
replace #warning with #pragma message (#1216) 2021-08-24 15:08:15 +01:00
Vy Nguyen dc1a97174d
Introduce accessors for currently public data members (threads and thread_index) (#1208)
* [benchmark] Introduce accessors for currently public data members `threads` and `thread_index`

Also deprecate the direct access to these fields.

Motivations:

Our internal library provides accessors for those fields because the styleguide disalows accessing classes' data members directly (even if they're const).
There has been a discussion to simply move internal library to make its fields public similarly to the OSS version here, however, the concern is that these kinds of direct access would prevent many types of future design changes (eg how/whether the values would be stored in the data member)

I think the concensus in the end is that we'd change the external library for this case.
AFAIK, there are three important third_party users that we'd need to migrate: tcmalloc, abseil and tensorflow.
Please let me know if I'm missing anyone else.

* [benchmark] Introduce accessors for currently public data members `threads` and `thread_index`

Also deprecate the direct access to these fields.

Motivations:

Our internal library provides accessors for those fields because the styleguide disalows accessing classes' data members directly (even if they're const).
There has been a discussion to simply move internal library to make its fields public similarly to the OSS version here, however, the concern is that these kinds of direct access would prevent many types of future design changes (eg how/whether the values would be stored in the data member)

I think the concensus in the end is that we'd change the external library for this case.
AFAIK, there are three important third_party users that we'd need to migrate: tcmalloc, abseil and tensorflow.
Please let me know if I'm missing anyone else.

* [benchmark] Introduce accessors for currently public data members `threads` and `thread_index`

Also deprecate direct access to `.thread_index` and make threads a private field

Motivations:

Our internal library provides accessors for those fields because the styleguide disalows accessing classes' data members directly (even if they're const).
There has been a discussion to simply move internal library to make its fields public similarly to the OSS version here, however, the concern is that these kinds of direct access would prevent many types of future design changes (eg how/whether the values would be stored in the data member)

I think the concensus in the end is that we'd change the external library for this case.
AFAIK, there are three important third_party users that we'd need to migrate: tcmalloc, abseil and tensorflow.
Please let me know if I'm missing anyone else.

* [benchmark] Introduce accessors for currently public data members `threads` and `thread_index`

Also deprecate direct access to `.thread_index` and make threads a private field

Motivations:

Our internal library provides accessors for those fields because the styleguide disalows accessing classes' data members directly (even if they're const).
There has been a discussion to simply move internal library to make its fields public similarly to the OSS version here, however, the concern is that these kinds of direct access would prevent many types of future design changes (eg how/whether the values would be stored in the data member)

I think the concensus in the end is that we'd change the external library for this case.
AFAIK, there are three important third_party users that we'd need to migrate: tcmalloc, abseil and tensorflow.
Please let me know if I'm missing anyone else.

* [benchmark] Introduce accessors for currently public data members `threads` and `thread_index`

Also deprecate direct access to `.thread_index` and make threads a private field

Motivations:

Our internal library provides accessors for those fields because the styleguide disalows accessing classes' data members directly (even if they're const).
There has been a discussion to simply move internal library to make its fields public similarly to the OSS version here, however, the concern is that these kinds of direct access would prevent many types of future design changes (eg how/whether the values would be stored in the data member)

I think the concensus in the end is that we'd change the external library for this case.
AFAIK, there are three important third_party users that we'd need to migrate: tcmalloc, abseil and tensorflow.
Please let me know if I'm missing anyone else.

* [benchmark] Introduce accessors for currently public data members `threads` and `thread_index`

Also deprecate direct access to `.thread_index` and make threads a private field

Motivations:

Our internal library provides accessors for those fields because the styleguide disalows accessing classes' data members directly (even if they're const).
There has been a discussion to simply move internal library to make its fields public similarly to the OSS version here, however, the concern is that these kinds of direct access would prevent many types of future design changes (eg how/whether the values would be stored in the data member)

I think the concensus in the end is that we'd change the external library for this case.
AFAIK, there are three important third_party users that we'd need to migrate: tcmalloc, abseil and tensorflow.
Please let me know if I'm missing anyone else.

* [benchmark] Introduce accessors for currently public data members `threads` and `thread_index`

Also deprecate direct access to `.thread_index` and make threads a private field

Motivations:

Our internal library provides accessors for those fields because the styleguide disalows accessing classes' data members directly (even if they're const).
There has been a discussion to simply move internal library to make its fields public similarly to the OSS version here, however, the concern is that these kinds of direct access would prevent many types of future design changes (eg how/whether the values would be stored in the data member)

I think the concensus in the end is that we'd change the external library for this case.
AFAIK, there are three important third_party users that we'd need to migrate: tcmalloc, abseil and tensorflow.
Please let me know if I'm missing anyone else.

* [benchmark] Introduce accessors for currently public data members `threads` and `thread_index`

Also deprecate direct access to `.thread_index` and make threads a private field

Motivations:

Our internal library provides accessors for those fields because the styleguide disalows accessing classes' data members directly (even if they're const).
There has been a discussion to simply move internal library to make its fields public similarly to the OSS version here, however, the concern is that these kinds of direct access would prevent many types of future design changes (eg how/whether the values would be stored in the data member)

I think the concensus in the end is that we'd change the external library for this case.
AFAIK, there are three important third_party users that we'd need to migrate: tcmalloc, abseil and tensorflow.
Please let me know if I'm missing anyone else.

* [benchmark] Introduce accessors for currently public data members `threads` and `thread_index`

Also deprecate direct access to `.thread_index` and make threads a private field

Motivations:

Our internal library provides accessors for those fields because the styleguide disalows accessing classes' data members directly (even if they're const).
There has been a discussion to simply move internal library to make its fields public similarly to the OSS version here, however, the concern is that these kinds of direct access would prevent many types of future design changes (eg how/whether the values would be stored in the data member)

I think the concensus in the end is that we'd change the external library for this case.
AFAIK, there are three important third_party users that we'd need to migrate: tcmalloc, abseil and tensorflow.
Please let me know if I'm missing anyone else.

* [benchmark] Introduce accessors for currently public data members `threads` and `thread_index`

Also deprecate direct access to `.thread_index` and make threads a private field

Motivations:

Our internal library provides accessors for those fields because the styleguide disalows accessing classes' data members directly (even if they're const).
There has been a discussion to simply move internal library to make its fields public similarly to the OSS version here, however, the concern is that these kinds of direct access would prevent many types of future design changes (eg how/whether the values would be stored in the data member)

I think the concensus in the end is that we'd change the external library for this case.
AFAIK, there are three important third_party users that we'd need to migrate: tcmalloc, abseil and tensorflow.
Please let me know if I'm missing anyone else.
2021-08-23 09:06:57 +01:00
Nico Weber 8fd49d6671
Fix a -Wunreachable-code-aggressive warning (#1214) 2021-08-19 16:09:49 +03:00
Dominic Hamon 990299fff8
install docs folder when installing library (#1212)
fixes #470
2021-08-17 22:16:40 +01:00
Vy Nguyen 4124223bf5
Change the default value of --benchmark_filter from "." to <empty> (#1207)
Both `.` and `<empty>` already means "run all benchmarks" here, as commented on this flag's declaration (and below around line 448-449).
So this is a NFC.

On the other hand, this help internally because internally, if the flag is empty (or if it's not a specified by a binary), we don't call the RunSpecifiedBenchmarks.
There is still a difference in what <empty> means internally (runs no benchmarks) and externally (runs all benchmarks).
But we can work around this.
2021-08-03 17:11:47 +01:00
Braedy 1067dfc91e
Remove dead code from PredictNumItersNeeded (#1206)
* Remove `min` with dead path.

When `isSignificant` is false, the smallest value `multiplier` can
approach is 14. Thus, min(10, multiplier) will always return 10.

Addresses part one of #1205.

* Remove always false condition.

   1. `multiplier <= 1.0` implies `i.seconds >= min_time * 1.4`
   2. By (1), `isSignficant` is true because `i.seconds > min_time * 1.4` implies `i.seconds > min_time` implies that `i.seconds / minTime > 1 > 0.1`. Thus, the ternary maintains the same multiplier value.
   3. `ShouldReportResults` is always called before `PredictNumItersNeeded`, if `i.seconds >= min_time` then the loop is broken and `PredictNumItersNeeded` is never called.
   4. 1 and 3 together imply that `multiplier <= 1.0` is never true.

Addresses part 2 of #1205.
2021-07-29 08:59:46 +01:00
Dominic Hamon 1fcb5c23d8 Don't return a reference when the callers all expect pointers.
Fixes #1196
2021-07-01 09:39:09 +01:00
Mircea Trofin 94f845ec4f
Fix typos (#1194) 2021-06-28 17:07:54 +01:00
Mircea Trofin 05a2ace713
Fix type warning on certain compilers (#1193)
repetition_indices is populated with size_t values, so typing it
accordingly.
2021-06-28 17:06:22 +01:00
Dominic Hamon 1799e1b9ec
prefix VLOG (#1187) 2021-06-24 18:55:37 +01:00
Dominic Hamon 6a5bf081d3
prefix macros to avoid clashes (#1186) 2021-06-24 18:21:59 +01:00
Dominic Hamon 5da5660429
Move flags inside the benchmark namespace (#1185)
This avoids clashes with other libraries that might define the same flags.
2021-06-24 16:50:19 +01:00
Dominic Hamon 62937f91b5
Add missing trailing commas (#1182)
* Add missing trailing commas

Fixes #1181

* Better trailing commas
2021-06-18 17:31:47 +01:00
PCMan c932169e76
Provide helpers to create integer lists for the given ranges. (#1179)
This can be used together with ArgsProduct() to allow multiple ranges
with different multipliers and mixing dense and sparse ranges.

Example:
BENCHMARK(MyTest)->ArgsProduct({
  CreateRange(0, 1024, /*multi=*/32),
  CreateRange(0, 100, /*multi=*/4),
  CreateDenseRange(0, 4, /*step=*/1)
});

Co-authored-by: Jen-yee Hong <pcmantw@google.com>
2021-06-16 12:56:24 +01:00
Michael Lippautz 5b7518482c
benchmark_runner.h: Remove superfluous semi colon (#1178)
Some downstream projects (e.g. V8) treat warnings as errors and cannot roll
the latest changes.
2021-06-15 13:28:55 +01:00
Roman Lebedev e991355c02
[NFCI] Drop warning to satisfy clang's -Wunused-but-set-variable diag (#1174)
Fixes https://github.com/google/benchmark/issues/1172
2021-06-09 11:52:12 +03:00
huajingyun f90215f1cc
Add support for new architecture loongarch (#1173) 2021-06-08 10:26:24 +01:00
Roman Lebedev fbc31405b2
Random interleaving of benchmark repetitions - the sequel (fixes #1051) (#1163)
Inspired by the original implementation by Hai Huang @haih-g
from https://github.com/google/benchmark/pull/1105.

The original implementation had design deficiencies that
weren't really addressable without redesign, so it was reverted.

In essence, the original implementation consisted of two separateable parts:
* reducing the amount time each repetition is run for, and symmetrically increasing repetition count
* running the repetitions in random order

While it worked fine for the usual case, it broke down when user would specify repetitions
(it would completely ignore that request), or specified per-repetition min time (while it would
still adjust the repetition count, it would not adjust the per-repetition time,
leading to much greater run times)

Here, like i was originally suggesting in the original review, i'm separating the features,
and only dealing with a single one - running repetitions in random order.

Now that the runs/repetitions are no longer in-order, the tooling may wish to sort the output,
and indeed `compare.py` has been updated to do that: #1168.
2021-06-03 21:16:54 +03:00
Dominic Hamon d17ea66551
Fix leak in test, and provide path to remove leak from library (#1169)
* Fix leak in test, and provide path to remove leak from library

* make doc change
2021-06-03 16:08:00 +01:00
Roman Lebedev 32cc607107
[NFCI] Make BenchmarkRunner non-internal to it's .cpp file
Currently the lifetime of a single BenchmarkRunner is constrained
to a RunBenchmark(), but that will have to change for interleaved
benchmark execution, because we'll need to keep it around to not
forget how much repetitions of an instance we've done.
2021-06-03 16:56:15 +03:00
Roman Lebedev 520573fecb
[NFCI] RunBenchmarks(): extract FlushStreams()/Report() functions
Based on original implementation by Hai Huang @haih-g in
https://github.com/google/benchmark/pull/1105
2021-06-03 16:44:20 +03:00
Roman Lebedev 0c1da0a713
Make 'complexity reports' cache per-family, not global (#1166)
While the current variant works, it assumes that all the instances of
a single family will be run together, with nothing inbetween them.
Naturally, that won't work once the runs may be interleaved.
2021-06-03 11:46:34 +03:00
Roman Lebedev 80a62618e8
Introduce per-family instance index (#1165)
Much like it makes sense to enumerate all the families,
it makes sense to enumerate stuff within families.
Alternatively, we could have a global instance index,
but i'm not sure why that would be better.

This will be useful when the benchmarks are run not in order,
for the tools to sort the results properly.
2021-06-02 23:45:41 +03:00
Roman Lebedev 4c2e32f1d0
Introduce "family index" field into JSON output (#1164)
It may be useful for those wishing to further post-process JSON results,
but it is mainly geared towards better support for run interleaving,
where results from the same family may not be close-by in the JSON.

While we won't be able to do much about that for outputs,
the tools can and perhaps should reorder the results to that
at least in their output they are in proper order, not run order.

Note that this only counts the families that were filtered-in,
so if e.g. there were three families, and we filtered-out
the second one, the two families (which were first and third)
will have family indexes 0 and 1.
2021-06-02 18:06:45 +03:00
Roman Lebedev e0a080d00e
BenchmarkFamilies::FindBenchmarks(): correctly use std::vector<>::reserve()
It takes the whole total new capacity, not the increase.
2021-06-02 13:28:05 +03:00
Roman Lebedev a54ef37aea
Ensure that we print repetition count even when it was specified via flag --benchmark_repetitions= 2021-06-02 12:34:00 +03:00
Dominic Hamon e025dd5a54
Revert "Implementation of random interleaving. (#1105)" (#1161)
This reverts commit a6a738c1cc.
2021-06-01 16:05:50 +01: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
Mariusz Wachowicz db2de74cc8
Fix pedantic compilation flag violation (#1156)
';' after method definition was removed.
Also, pedantic flag is now uncommented in CMakeList.txt.
2021-05-21 09:48:20 +01:00
haih-g a6a738c1cc
Implementation of random interleaving. (#1105)
* Implementation of random interleaving. See
http://github.com/google/benchmark/issues/1051 for the feature requests.

Committer: Hai Huang (http://github.com/haih-g)

On branch fr-1051
Changes to be committed:
modified:   include/benchmark/benchmark.h
modified:   src/benchmark.cc
new file:   src/benchmark_adjust_repetitions.cc
new file:   src/benchmark_adjust_repetitions.h
modified:   src/benchmark_api_internal.cc
modified:   src/benchmark_api_internal.h
modified:   src/benchmark_register.cc
modified:   src/benchmark_runner.cc
modified:   src/benchmark_runner.h
modified:   test/CMakeLists.txt
new file:   test/benchmark_random_interleaving_gtest.cc

* Fix benchmark_random_interleaving_gtest.cc for fr-1051

Committer: Hai Huang <haih@google.com>

On branch fr-1051
Your branch is up to date with 'origin/fr-1051'.

Changes to be committed:
modified:   src/benchmark.cc
modified:   src/benchmark_runner.cc
modified:   test/benchmark_random_interleaving_gtest.cc

* Fix macos build for fr-1051

Committer: Hai Huang <haih@google.com>

On branch fr-1051
Your branch is up to date with 'origin/fr-1051'.

Changes to be committed:
modified:   src/benchmark_api_internal.cc
modified:   src/benchmark_api_internal.h
modified:   src/benchmark_runner.cc

* Fix macos and windows build for fr-1051.

Committer: Hai Huang <haih@google.com>

On branch fr-1051
Your branch is up to date with 'origin/fr-1051'.

Changes to be committed:
modified:   src/benchmark_runner.cc

* Fix benchmark_random_interleaving_test.cc for macos and windows in fr-1051

Committer: Hai Huang <haih@google.com>

On branch fr-1051
Your branch is up to date with 'origin/fr-1051'.

Changes to be committed:
modified:   test/benchmark_random_interleaving_gtest.cc

* Fix int type benchmark_random_interleaving_gtest for macos in fr-1051

Committer: Hai Huang <haih@google.com>

On branch fr-1051
Your branch is up to date with 'origin/fr-1051'.

Changes to be committed:
modified:   test/benchmark_random_interleaving_gtest.cc

* Address dominichamon's comments 03/29 for fr-1051

Committer: Hai Huang <haih@google.com>

On branch fr-1051
Your branch is up to date with 'origin/fr-1051'.

Changes to be committed:
modified:   src/benchmark.cc
modified:   src/benchmark_api_internal.cc
modified:   src/benchmark_api_internal.h
modified:   test/benchmark_random_interleaving_gtest.cc

* Address dominichamon's comment on default min_time / repetitions for fr-1051.
Also change sentinel of random_interleaving_repetitions to -1. Hopefully it
fixes the failures on Windows.

Committer: Hai Huang <haih@google.com>

On branch fr-1051
Your branch is up to date with 'origin/fr-1051'.

Changes to be committed:
modified:   src/benchmark.cc
modified:   src/benchmark_api_internal.cc
modified:   src/benchmark_api_internal.h

* Fix windows test failures for fr-1051

Committer: Hai Huang <haih@google.com>

On branch fr-1051
Your branch is up to date with 'origin/fr-1051'.

Changes to be committed:
modified:   src/benchmark_api_internal.cc
modified:   src/benchmark_runner.cc

* Add license blurb for fr-1051.

Committer: Hai Huang <haih@google.com>

On branch fr-1051
Your branch is up to date with 'origin/fr-1051'.

Changes to be committed:
modified:   src/benchmark_adjust_repetitions.cc
modified:   src/benchmark_adjust_repetitions.h

* Switch to std::shuffle() for fr-1105.

Committer: Hai Huang <haih@google.com>

On branch fr-1051
Your branch is up to date with 'origin/fr-1051'.

Changes to be committed:
modified:   src/benchmark.cc

* Change to 1e-9 in fr-1105

Committer: Hai Huang <haih@google.com>

On branch fr-1051
Your branch is up to date with 'origin/fr-1051'.

Changes to be committed:
modified:   src/benchmark_adjust_repetitions.cc

* Fix broken build caused by bad merge for fr-1105.

Committer: Hai Huang <haih@google.com>

On branch fr-1051
Your branch is up to date with 'origin/fr-1051'.

Changes to be committed:
modified:   src/benchmark_api_internal.cc
modified:   src/benchmark_runner.cc

* Fix build breakage for fr-1051.

Committer: Hai Huang <haih@google.com>

On branch fr-1051
Your branch is up to date with 'origin/fr-1051'.

Changes to be committed:
modified:   src/benchmark.cc
modified:   src/benchmark_api_internal.cc
modified:   src/benchmark_api_internal.h
modified:   src/benchmark_register.cc
modified:   src/benchmark_runner.cc

* Print out reports as they come in if random interleaving is disabled (fr-1051)

Committer: Hai Huang <haih@google.com>

On branch fr-1051
Your branch is up to date with 'origin/fr-1051'.

Changes to be committed:
modified:   src/benchmark.cc

* size_t, int64_t --> int in benchmark_runner for fr-1051.

Committer: Hai Huang <haih@google.com>

On branch fr-1051
Your branch is up to date with 'origin/fr-1051'.

Changes to be committed:
modified:   src/benchmark_runner.cc
modified:   src/benchmark_runner.h

* Address comments from dominichamon for fr-1051

Committer: Hai Huang <haih@google.com>

On branch fr-1051
Your branch is up to date with 'origin/fr-1051'.

Changes to be committed:
modified:   src/benchmark.cc
modified:   src/benchmark_adjust_repetitions.cc
modified:   src/benchmark_adjust_repetitions.h
modified:   src/benchmark_api_internal.cc
modified:   src/benchmark_api_internal.h
modified:   test/benchmark_random_interleaving_gtest.cc

* benchmar_indices --> size_t to make CI pass: fr-1051

Committer: Hai Huang <haih@google.com>

On branch fr-1051
Your branch is up to date with 'origin/fr-1051'.

Changes to be committed:
modified:   src/benchmark.cc

* Fix min_time not initialized issue for fr-1051.

Committer: Hai Huang <haih@google.com>

On branch fr-1051
Your branch is up to date with 'origin/fr-1051'.

Changes to be committed:
modified:   src/benchmark_api_internal.cc
modified:   src/benchmark_api_internal.h

* min_time --> MinTime in fr-1051.

Committer: Hai Huang <haih@google.com>

On branch fr-1051
Your branch is up to date with 'origin/fr-1051'.

Changes to be committed:
modified:   src/benchmark_api_internal.cc
modified:   src/benchmark_api_internal.h
modified:   src/benchmark_runner.cc

* Add doc for random interleaving for fr-1051

Committer: Hai Huang <haih@google.com>

On branch fr-1051
Your branch is up to date with 'origin/fr-1051'.

Changes to be committed:
modified:   README.md
new file:   docs/random_interleaving.md

Co-authored-by: Dominic Hamon <dominichamon@users.noreply.github.com>
2021-05-20 17:09:16 +01:00
Mircea Trofin e539e807da
[PFM] Extend perf counter support to multi-threaded cases. (#1153)
* Extend perf counter support to multi-threaded cases.

* Docs update

* const-ed Snapshot
2021-05-19 09:49:05 +01:00
Dominic Hamon 3b508fad1f
Refactor BenchmarkInstance (#1148)
* Refactor BenchmarkInstance (precursor to #1105)

* fix bazel (debug) build

* clang-format on header

* fix build error on g++-4.8
2021-05-10 17:12:09 +01:00
Roman Lebedev a2e8a8a9db
Clean -Wreserved-identifier instances (#1143) 2021-05-06 20:31:14 +01:00
Mircea Trofin e0826edea7
Fix StrSplit empty string case (#1142)
This also fixes #1135. Because StrSplit was returning a vector with an
empty string, it was treated by PerfCounters::Create as a legitimate ask
for setting up a counter with that name. The empty vector is understood
by PerfCounters as "just return NoCounters()".
2021-05-06 19:12:36 +01:00
Dominic Hamon d0c227ccfd
Add API to benchmark allowing for custom context to be added (#1137)
* Add API to benchmark allowing for custom context to be added

Fixes #525

* add docs

* Add context flag output to JSON reporter

* Plumb everything into the global context.

* Add googletests for custom context

* update docs with duplicate key behaviour
2021-05-05 12:08:23 +01:00
Dominic Hamon 33c133a206
Add benchmark_context flag that allows per-run custom context. (#1127)
* Add `benchmark_context` flag that allows per-run custom context.

Add support for key-value flags in general.
Added test for key-value flags.
Added `benchmark_context` flag.
Output content of `benchmark_context` to base reporter.

Solves the first part of #525.

* Docs and better help
2021-05-04 14:36:11 +01:00
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 264976def3
Fix windows warning on type conversion (#1121) 2021-04-27 08:24:27 +01:00
Roman Lebedev c05843a9f6
[sysinfo] Fix CPU Frequency reading on AMD Ryzen CPU's (#1117)
Currently, i get:
```
Run on (32 X 7326.56 MHz CPU s)
CPU Caches:
  L1 Data 32 KiB (x16)
  L1 Instruction 32 KiB (x16)
  L2 Unified 512 KiB (x16)
  L3 Unified 32768 KiB (x2)
```
which seems mostly right, except that the frequency is rather bogus.
Yes, i guess the CPU could theoretically achieve that,
but i have 3.6GHz configured, and scaling disabled.
So we clearly read the wrong thing.

With this fix, i now get the expected
```
Run on (32 X 3598.53 MHz CPU s)
CPU Caches:
  L1 Data 32 KiB (x16)
  L1 Instruction 32 KiB (x16)
  L2 Unified 512 KiB (x16)
  L3 Unified 32768 KiB (x2)
```
2021-04-23 14:33:22 +03:00
Matt Armstrong 69054ae50e
Use fewer ramp up repetitions when KeepRunningBatch is used (#1113)
Use the benchmark's reported iteration count when estimating
iterations for the next repetition, rather than the requested
iteration count.  When the benchmark uses KeepRunningBatch the actual
iteration count can be larger than the one the runner requested.

Prior to this fix the runner was underestimating the next iteration
count, sometimes significantly so.  Consider the case of a benchmark
using a batch size of 1024.  Prior to this change, the benchmark
runner would attempt iteration counts 1, 10, 100 and 1000, yet the
benchmark itself would do the same amount of work each time: a single
batch of 1024 iterations.  The discrepancy could also contribute to
estimation errors once the benchmark time reached 10% of the target.
For example, if the very first batch of 1024 iterations reached 10% of
benchmark_min_min time, the runner would attempt to scale that to 100%
from a basis of one iteration rather than 1024.

This bug was particularly noticeable in benchmarks with large batch
sizes, especially when the benchmark also had slow set up or tear down
phases.

With this fix in place it is possible to use KeepRunningBatch to
achieve a kind of "minimum iteration count" feature by using a larger
fixed batch size.  For example, a benchmark may build a map of 500K
elements and test a "find" operation.  There is no point in running
"find" just 1, 10, 100, etc., times.  The benchmark can now pick a
batch size of something like 10K, and the runner will arrive at the
final max iteration count with in noticeably fewer repetitions.
2021-04-20 07:16:05 +01:00
Chris Lalancette 07578d82e0
Shrink the tz_offset size to 41. (#1110)
When building with gcc TSan on, and in Debug mode, we see a warning
like:

benchmark/src/timers.cc: In function ‘std::string benchmark::LocalDateTimeString()’:
src/timers.cc:241:15: warning: ‘char* strncat(char*, const char*, size_t)’ output may be truncated copying 108 bytes from a string of length 127 [-Wstringop-truncation]
  241 |   std::strncat(storage, tz_offset, sizeof(storage) - timestamp_len - 1);
      |   ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

While this is essentially a false positive (we never expect
the number of bytes in tz_offset to be too large), the compiler can't
actually tell that.  Shrink the size of tz_offset to a smaller, but still safe
size to eliminate this warning.

Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>
2021-04-09 17:32:00 +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
Phoenix Meadowlark a9b9471c02
Fix typo in invalid file name error message. (#1094) 2021-02-22 09:55:07 +00:00
SSE4 d90321ff7a
- add support for Elbrus 2000 (e2k) (#1091)
Signed-off-by: SSE4 <tomskside@gmail.com>
2021-02-14 17:45:57 +03:00
Michał Janiszewski ea5a5bbff4
Add MSVC ARM64 support for reading clocks (#1052)
Lacks CMake support, see https://github.com/google/benchmark/pull/1090
2021-02-12 13:30:26 +03:00
Scott K Logan 17a6b21ee1
Fix Range when starting at zero (#1073)
The existing behavior results in the `0` value being added twice. Since
`lo` is always added to `dst`, we never want to explicitly add `0` if
`lo` is equal to `0`.
2020-11-26 11:12:45 +00:00
Steven Wan d9abf01763
Rename 'mftbl' to 'mftb' (#1069)
* Rename 'mftbl' to 'mftb'

* Add my name to the contributor list
2020-11-03 09:08:46 +00:00
Abhina Sree a9704c268d
Nanosleep workaround for z/OS in sleep.cc (#1067)
* z/OS does not support nanosleep, add workaround to use sleep() and usleep() instead

* change unsigned to int, and fix while loop
2020-10-29 08:49:02 +00:00
Fanbo Meng dce3322a54
Add support for z/OS XL compiler inline asm syntax (#1063)
On s390 architecture, z/OS XL compiler uses HLASM inline assembly, which has different syntax and needs to be distinguished to avoid compilation error.
2020-10-21 16:39:54 +01:00
Sergei Trofimovich 3d1c267768
src/benchmark_register.h: add missing <limits> inclusion (#1060)
Noticed missing header when was building llvm with gcc-11:

```
llvm-project/llvm/utils/benchmark/src/benchmark_register.h:17:30:
  error: 'numeric_limits' is not a member of 'std'
   17 |   static const T kmax = std::numeric_limits<T>::max();
      |                              ^~~~~~~~~~~~~~
```
2020-10-15 11:12:40 +03:00
Michael Neumann af72911f2f
Add support for DragonFly BSD (#1058)
Without this commit, compilation fails on DragonFly with the following message:

```
/home/mneumann/Dev/benchmark.old/src/sysinfo.cc:446:2: error: #warning "HOST_NAME_MAX not defined. using 64" [-Werror=cpp]
^~~~~~~
```

Also note that the sysctl is actually `hw.tsc_frequency` on DragonFly:

```
$ sysctl hw.tsc_frequency
hw.tsc_frequency: 3498984022
```

Tested on:

```
$ uname -a
DragonFly box.localnet 5.9-DEVELOPMENT DragonFly v5.9.0.742.g4b29dd-DEVELOPMENT #5: Tue Aug 18 00:21:31 CEST 2020
```
2020-10-12 23:41:49 +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
Dominic Hamon 5b72b6c2da
Remove "BENCHMARK_" prefix from env var version of command line flags (#997)
As noted in #995, this causes issues when the command line flag already
starts with "benchmark_", which they all do.

Not caught by tests as the test flags didn't start with "benchmark".

Fixes #995
2020-08-18 10:02:20 +01:00
Dominic Hamon 1302d2ce09
Add missing breaks for QNX cache counting (#1012) 2020-07-30 09:51:48 +01:00
Alexander Enaldiev 9901011880
JSONReporter: don't report on scaling if we didn't get it (#1005) (#1008)
* JSONReporter: don't report on scaling if we didn't get it (#1005)

* JSONReporter: fix due to review (std::pair<bool, bool> -> enum)

* JSONReporter: scaling: fix the algo (due to review discussion)

* benchmark.h: revert to old-fashioned enum's (C++03 compatibility); rreporter_output_test: let's skip scaling
2020-07-28 12:46:07 +01:00
Reid Paape 15e6dfd718
timers: silence strncat truncation warning (#984) 2020-06-17 14:58:12 +03:00
Brian Wolfe 7cc06ef80c timers: just make the buffers big enough 2020-06-15 16:16:19 -07:00
Brian Wolfe f25ea40ae1 timers: use snprintf instead of sprintf 2020-06-15 14:16:20 -07:00
Brian Wolfe f6ac240cd2 timers: silence format overflow warning 2020-06-15 14:02:15 -07:00
Brian Wolfe 99c52f1414
use rfc3339-formatted timestamps in output [output format change] (#965)
* timestamp: use rfc3339-formatted timestamps in output

Replace localized timestamps with machine-readable IETF RFC 3339 format
timestamps. This is an attempt to make the output timestamps easily
machine-readable. ISO8601 specifies standards for time interchange
formats. IETF RFC 3339: https://tools.ietf.org/html/rfc3339 defines a
subset of these for use in the internet. The general form for these
timestamps is:

YYYY-MM-DDTHH:mm:SS[+-]hhmm

This replaces the localized time formats that are currently being used
in the benchmark output to prioritize interchangeability and
machine-readability.

This might break existing programs that rely on the particular date-time
format. This might also may make times less human readable. RFC3339 was
intended to balance human readability and simplicity for machine
readability, but it is primarily intended as an internal representation.

* timers: remove utc string formatting

We only ever need local time printing. Remove the UTC printing
and cosnolidate the logic slightly.

* timers: manually create rfc3339 string

The C++ standard library does not output the time offset in RFC3339
format, it is missing the : between hours and minutes. VS does not
appear to support timezone information by default. To avoid adding too
much complexity to benchmark around timezone handling e.g. a full
date library like https://github.com/HowardHinnant/date, we fall back
to outputting GMT time with a -00:00 offset for those cases.

* timers: use reentrant form for localtime_r & tmtime_r

For non-windows, use the reentrant form for the time conversion
functions.

* timers: cleanup

Use strtol instead of brittle moving characters around.

* timers: only call strftime twice.

Also size buffers to known maximum necessary size and name constants
more appropriately.

* timers: fix unused variable warning
2020-06-15 17:28:17 +01:00
Kai Wolf 56898e9a92
Add missing <cerrno> header include - fixes Android build (#960)
* Add missing <cerrno> header

This commit fixes a current build error on Android where 'errno' is an unidentified
symbol due to a missing header

* Update string_util.cc

Conditionally adds <cerrno> if BENCHMARK_STL_ANDROID_GNUSTL is defined
2020-04-23 14:19:19 +03:00
Luís Marques ecc1685340
Fix formatting issues introduced by a77d5f7 (#959) 2020-04-17 19:31:49 +03:00
Keith Moyer 8cead00783
Remove warnings for internal use of CSVReporter (#956)
In a previous commit[1], diagnostic pragmas were used to avoid this
warning. However, the incorrect warning flag was indicated, leaving the
warning in place. -Wdeprecated is for deprecated features while
-Wdeprecated-declarations for deprecated functions, variables, and
types[2].

[1] c408461983
[2] https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
2020-04-14 10:20:22 +01:00
Luís Marques a77d5f70ef
Fix cycleclock::Now for RISC-V and PPC (#955)
Fixes the following issues with the implementation of `cycleclock::Now`:

- The RISC-V implementation wouldn't compile due to a typo;

- Both the PPC and RISC-V implementation's asm statements lacked the
  volatile keyword. This resulted in the repeated read of the counter's
  high part being optimized away, so overflow wasn't handled at all.
  Multiple counter reads could also be misoptimized, especially in LTO
  scenarios.

- Relied on the zero/sign-extension of inline asm operands, which isn't
  guaranteed to occur and differs between compilers, namely GCC and Clang.

The PowerPC64 implementation was improved to do a single 64-bit read of
the time-base counter.

The RISC-V implementation was improved to do the overflow handing in
assembly, since Clang would generate a branch, defeating the purpose
of the non-branching counter reading approach.
2020-04-10 17:02:13 +01:00
Dominic Hamon 0ab2c2906b
Fix type conversion warnings. (#951)
* Fix type conversion warnings.

Fixes #949

Tested locally (Linux/clang), but warnings are on MSVC so may differ.

* Drop the ULP so the double test passes
2020-04-06 13:52:09 +01:00
Roman Lebedev 70d89ac519
Revert "Add d postfix to Debug libraries (#923)"
This reverts commit 5ce2429af7.

Reverts https://github.com/google/benchmark/pull/923
Reopens https://github.com/google/benchmark/issues/922
Fixes https://github.com/google/benchmark/issues/928
Closes https://github.com/google/benchmark/pull/930

See discussion in https://github.com/google/benchmark/issues/928
this broke pkg-config support, since there we don't account
for the suffix, nor is it trivial to do so.
2020-03-16 14:29:27 +03: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
Ben Clayton 8982e1ee6a
Fix MSVC warning. (#935)
This fixes the Visual Studio 2019 warning:

`C4244: '=': conversion from 'int' to 'char', possible loss of data`

When implicitly casting the return value of tolower() (int) to char.

Fixes: #932
2020-02-08 02:48:01 +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
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
Tetsuo Kiso 0811f1d782 Fix typo in mutex.h (#917) 2019-12-15 13:38:54 +03:00
Roman Lebedev 367119482f CPU caches are binary units, not SI. (#911)
As disscussed in https://github.com/google/benchmark/issues/899,
it is all but certain that the multiplier should be 1024, not 1000.

Fixes https://github.com/google/benchmark/issues/899
2019-12-02 09:29:16 +00:00
Dominic Hamon 49aa79b635
update header guard to match style 2019-11-25 13:05:13 +00:00
Roman Lebedev 51d991f1d7
ParseCommandLineFlags(): do not dereference argc if it is null
Higher up we dereference argc only if it is not null.
But here we do no such check.
2019-11-23 00:23:11 +03:00
Roman Lebedev c22c266eaf
JSONReporter: RoundDouble(): use std::lround() to round double to int
From clang-tidy bugprone-incorrect-roundings check:
> casting (double + 0.5) to integer leads to incorrect rounding; consider using lround (#include <cmath>) instead
2019-11-23 00:19:02 +03:00
Roman Lebedev cc7f50e126
BenchmarkRunner: use std::lround() to round double to int
From clang-tidy bugprone-incorrect-roundings check:
> casting (double + 0.5) to integer leads to incorrect rounding; consider using lround (#include <cmath>) instead
2019-11-23 00:18:28 +03:00
Roman Lebedev 173aff82ee
src/counter.h: add header guard 2019-11-22 15:06:43 +03:00
András Leitereg cf446a18bf Remove superfluous cache line scaling in JSON reporter. (#896)
Cache size is already stored in bytes.
2019-10-24 22:13:03 +03:00
Martin Blanchard bc200ed8ee Read options from environment (#881) (#883)
Initialize option flags from environment variables values if they are defined, eg. `BENCHMARK_OUT=<filename>` for `--benchmark_out=<filename>`. Command line flag value always prevails.

Fixes https://github.com/google/benchmark/issues/881.
2019-10-23 11:07:08 +03:00
Geoffrey Martin-Noble b874e72208 Guard definition of __STDC_FORMAT_MACROS in ifndef (#875)
This macro is sometimes already defined and redefining it results
in build errors.
2019-09-23 10:53:09 +01:00
Geoffrey Martin-Noble 7411874d95 Define HOST_NAME_MAX for NaCl and RTEMS (#876)
These OS's don't always have HOST_NAME_MAX defined, resulting in
build errors.

A few related changes as well:
* Only define HOST_NAME_MAX if it's not already defined. There are
  some cases where this is already defined, e.g. with NaCl if
  __USE_POSIX is set. To avoid all of these, only define it if it's
  not already defined.
* Default HOST_NAME_MAX to 64 and issue a #warning. Having the wrong
  max length is pretty harmless. The name just ends up getting
  truncated and this is only for printing debug info. Because we're
  constructing a std::string from a char[] (so defined length), we
  don't need to worry about gethostname's undefined behavior for
  whether the truncation is null-terminated when the hostname
  doesn't fit in HOST_NAME_MAX. Of course, this doesn't help people
  who have -Werror set, since they'll still get a warning.
2019-09-23 10:38:34 +01:00
Sayan Bhattacharjee 7ee72863fd Remove unused doc argument from DEFINE_ macros. (#857)
- Adresses : #856

  - The unused `doc` argument was removed from the `DEFINE_` macros in
    `commandlineflags.h`

  - Converted all the previous `doc` strings passed to the `DEFINE_`
    macros to multiline comments.
2019-08-21 14:12:03 -07: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
Eric Fiselier c408461983 Disable deprecated warnings when touching CSVReporter internally.
The CSVReporter is deprecated, but we still need to reference it in
a few places. To avoid breaking the build when warnings are errors,
we need to disable the warning when we do so.
2019-08-07 15:55:40 -04:00
Roman Lebedev 8e48105d46 CMake; windows: link to lowercase 'shlwapi' - consistent with headers (#840)
The filenames are consistently inconsistent in windows world, might
have something to do with default file system being case-insensitive.
While the native MinGW buils were fixed in 5261307982
that only addressed the headers, but not libraries.
The problem remains when one tries to do a MinGW cross-build from
case-sensitive filesystem.
2019-07-22 13:42:12 +01:00