grpc
third_party
benchmark
src
benchmark/src/counter.cc
Go to the documentation of this file.
1
// Copyright 2015 Google Inc. All rights reserved.
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
// http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14
15
#include "
counter.h
"
16
17
namespace
benchmark
{
18
namespace
internal
{
19
20
double
Finish
(
Counter
const
& c,
IterationCount
iterations,
double
cpu_time,
21
double
num_threads
) {
22
double
v
= c.value;
23
if
(c.flags &
Counter::kIsRate
) {
24
v
/= cpu_time;
25
}
26
if
(c.flags &
Counter::kAvgThreads
) {
27
v
/=
num_threads
;
28
}
29
if
(c.flags &
Counter::kIsIterationInvariant
) {
30
v
*= iterations;
31
}
32
if
(c.flags &
Counter::kAvgIterations
) {
33
v
/= iterations;
34
}
35
36
if
(c.flags &
Counter::kInvert
) {
// Invert is *always* last.
37
v
= 1.0 /
v
;
38
}
39
return
v
;
40
}
41
42
void
Finish
(
UserCounters
* l,
IterationCount
iterations,
double
cpu_time,
43
double
num_threads
) {
44
for
(
auto
& c : *l) {
45
c.second.value =
Finish
(c.second, iterations, cpu_time,
num_threads
);
46
}
47
}
48
49
void
Increment
(
UserCounters
* l,
UserCounters
const
&
r
) {
50
// add counters present in both or just in *l
51
for
(
auto
& c : *l) {
52
auto
it
=
r
.find(c.first);
53
if
(
it
!=
r
.end()) {
54
c.second.value = c.second +
it
->second;
55
}
56
}
57
// add counters present in r, but not in *l
58
for
(
auto
const
& tc :
r
) {
59
auto
it
= l->find(tc.first);
60
if
(
it
== l->end()) {
61
(*l)[tc.first] = tc.second;
62
}
63
}
64
}
65
66
bool
SameNames
(
UserCounters
const
& l,
UserCounters
const
&
r
) {
67
if
(&l == &
r
)
return
true
;
68
if
(l.size() !=
r
.size()) {
69
return
false
;
70
}
71
for
(
auto
const
& c : l) {
72
if
(
r
.find(c.first) ==
r
.end()) {
73
return
false
;
74
}
75
}
76
return
true
;
77
}
78
79
}
// end namespace internal
80
}
// end namespace benchmark
benchmark::Counter::kInvert
@ kInvert
Definition:
benchmark/include/benchmark/benchmark.h:408
benchmark::Counter::kIsRate
@ kIsRate
Definition:
benchmark/include/benchmark/benchmark.h:388
regen-readme.it
it
Definition:
regen-readme.py:15
benchmark
Definition:
bm_alarm.cc:55
benchmark::Counter::kIsIterationInvariant
@ kIsIterationInvariant
Definition:
benchmark/include/benchmark/benchmark.h:396
benchmark::Counter::kAvgThreads
@ kAvgThreads
Definition:
benchmark/include/benchmark/benchmark.h:391
benchmark::internal::Increment
void Increment(UserCounters *l, UserCounters const &r)
Definition:
benchmark/src/counter.cc:49
benchmark::IterationCount
uint64_t IterationCount
Definition:
benchmark/include/benchmark/benchmark.h:451
setup.v
v
Definition:
third_party/bloaty/third_party/capstone/bindings/python/setup.py:42
counter.h
benchmark::Counter
Definition:
benchmark/include/benchmark/benchmark.h:382
benchmark::Counter::kAvgIterations
@ kAvgIterations
Definition:
benchmark/include/benchmark/benchmark.h:403
benchmark::UserCounters
std::map< std::string, Counter > UserCounters
Definition:
benchmark/include/benchmark/benchmark.h:439
benchmark::internal::Finish
double Finish(Counter const &c, IterationCount iterations, double cpu_time, double num_threads)
Definition:
benchmark/src/counter.cc:20
fix_build_deps.r
r
Definition:
fix_build_deps.py:491
num_threads
static volatile int num_threads
Definition:
benchmark-thread.c:30
internal
Definition:
benchmark/test/output_test_helper.cc:20
benchmark::internal::SameNames
bool SameNames(UserCounters const &l, UserCounters const &r)
Definition:
benchmark/src/counter.cc:66
grpc
Author(s):
autogenerated on Fri May 16 2025 02:58:04