1 // Copyright 2015 Google Inc. All rights reserved.
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
7 // http://www.apache.org/licenses/LICENSE-2.0
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.
20 double Finish(Counter
const& c
, IterationCount iterations
, double cpu_time
,
23 if (c
.flags
& Counter::kIsRate
) {
26 if (c
.flags
& Counter::kAvgThreads
) {
29 if (c
.flags
& Counter::kIsIterationInvariant
) {
32 if (c
.flags
& Counter::kAvgIterations
) {
36 if (c
.flags
& Counter::kInvert
) { // Invert is *always* last.
42 void Finish(UserCounters
* l
, IterationCount iterations
, double cpu_time
,
45 c
.second
.value
= Finish(c
.second
, iterations
, cpu_time
, num_threads
);
49 void Increment(UserCounters
* l
, UserCounters
const& r
) {
50 // add counters present in both or just in *l
52 auto it
= r
.find(c
.first
);
54 c
.second
.value
= c
.second
+ it
->second
;
57 // add counters present in r, but not in *l
58 for (auto const& tc
: r
) {
59 auto it
= l
->find(tc
.first
);
61 (*l
)[tc
.first
] = tc
.second
;
66 bool SameNames(UserCounters
const& l
, UserCounters
const& r
) {
67 if (&l
== &r
) return true;
68 if (l
.size() != r
.size()) {
71 for (auto const& c
: l
) {
72 if (r
.find(c
.first
) == r
.end()) {
79 } // end namespace internal
80 } // end namespace benchmark