Questions tagged [google-benchmark]
84 questions
3
votes
1 answer
Google benchmark negative perf counters
I'm using Google/benchmark for a project, and I just started playing around with the --benchmark_perf_counters flag. Clearly I'm doing something wrong, since the perf counters are often negative. I'm assuming it's an issue w/ overflow, but I still…

Throckmorton
- 564
- 4
- 17
3
votes
1 answer
The time shown in Google-benchmark result does not make sense
I am bench-marking some example functions on my processsor, each core running at 2 GHz. Here are the functions being bench-marked. Also, available on quick-bench
#include
#include
#include
class Base
{
public:
…

talekeDskobeDa
- 372
- 2
- 13
3
votes
2 answers
What is the meaning of Google Benchmark Iteration?
I am working with Google Benchmark to measure the execution time of some code. For example, I wrote the following code to measure its execution time performance.
#include
// Alternatively, can add libraries using linker…
user12014522
3
votes
0 answers
fatal error: benchmark/benchmark.h: No such file or directory
Does anybody know what the following error message means?
fatal error: benchmark/benchmark.h: No such file or directory
#include benchmark/benchmark.h/
I should say that I have just installed Google Protobuf.

M R
- 31
- 5
2
votes
1 answer
Google Benchmark: "***WARNING*** Library was built as DEBUG. Timings may be affected."
In ~/install/benchmark, I have checked out Google Benchmark (https://github.com/google/benchmark) and built it in Release mode according to the instructions here.
In ~/personal-projects/benchmarking, I have my own code with a BUILD file and a…

bun9
- 161
- 8
2
votes
1 answer
How to change the increment or step or scale of a Google Benchmark 'Range()' function
I have a very simple Google Benchmark program that benchmarks a function taking two integer arguments, I'm trying to use the benchmark to see how exactly does the time the function takes increase as the second argument's value increases from 1 to…

YousefOnWeb
- 48
- 1
- 7
2
votes
0 answers
Google test's `TestWithParam` alternative in Google benchmark?
In google test, people can use TestWithParam for customized parameter in a fixture. That is to say, write a class that inheritates testing::TestWithParam class, in which Customed_Params is my own defined class that holds customed…

ChrisZZ
- 1,521
- 2
- 17
- 24
2
votes
0 answers
Would Google Benchmark library call testing blocks several times?
I have this minimal example of Google Benchmark usage.
The weird thing is that "42" is printed a number of times (4), not just once.
I understand that the library has to run things several times to gain statistics but this I though that this is…

alfC
- 14,261
- 4
- 67
- 118
2
votes
2 answers
How to force google benchmark to run multiple iterations?
I use google benchmark to test two C++ functions. One runs for ~630,000,000 ns and one runs for ~1,000,000,000 ns. But both only run one iteration. How can I force the benchmark to run more iterations? I would like it to run at least 10 times.

Harper
- 1,794
- 14
- 31
2
votes
1 answer
cannot create std::vector larger than max_size() for size below max_size
I am running google benchmark for some basic cache testing and I get the following error:
terminate called after throwing an instance of 'std::length_error'
what(): cannot create std::vector larger than max_size()
However, I am printing the…

Mike
- 3,775
- 8
- 39
- 79
2
votes
0 answers
Benchmark C `std::isdigit`
I am trying to benchmark the function std::isdigit from the header cctype (the one inherited from C, just to be clear).
The code snippet is the following:
void BM_IsDigit_C(::benchmark::State& state) {
const char c = GenerateRandomChar();
for…

BiagioF
- 9,368
- 2
- 26
- 50
2
votes
1 answer
Google Benchmark, how to call code only once?
I have a code snippet I need to benchmark composed of 2 parts, first the state needs to be set exactly once, next I need to actually benchmark a function.
My code looks like this:
static void BM_LoopTime(benchmark::State& state)
{
MasterEngine…

Makogan
- 8,208
- 7
- 44
- 112
2
votes
1 answer
Google benchmark fixture: reuse vectors across multiple benchmarks
I want to run multiple benchmarks using google benchmark library after loading up a large file. I use the following code for this purpose. The function read_collection() loads the contents of the file and the benchmark Build processes the contents…

Unni
- 5,348
- 6
- 36
- 55
2
votes
0 answers
Why does google benchmark csv_reporter print out unused headers?
We are using Google (micro) Benchmark (https://github.com/google/benchmark) to do benchmarking. When we display the results, the benchmark displays all headers (even unused ones). The benchmark results are displayed using csv_reporter…

Snowman
- 1,503
- 1
- 17
- 39
2
votes
1 answer
Benchmark on quick-bench.com is much faster with disabled optimizations
I've created a very simple benchmark for illustration of short string optimization and run it on quick-bench.com. The benchmark works very well as for the comparison of SSO-disabled/enabled string class and the results are very consistent with both…

Daniel Langr
- 22,196
- 3
- 50
- 93