Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(397)

Side by Side Diff: base/metrics/sample_map.cc

Issue 1485763002: Merge multiple histogram snapshots into single one for reporting. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@shared-histograms
Patch Set: added merge test Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/metrics/sample_map.h" 5 #include "base/metrics/sample_map.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 8
9 namespace base { 9 namespace base {
10 10
(...skipping 20 matching lines...) Expand all
31 } 31 }
32 32
33 Count SampleMap::TotalCount() const { 33 Count SampleMap::TotalCount() const {
34 Count count = 0; 34 Count count = 0;
35 for (const auto& entry : sample_counts_) { 35 for (const auto& entry : sample_counts_) {
36 count += entry.second; 36 count += entry.second;
37 } 37 }
38 return count; 38 return count;
39 } 39 }
40 40
41 void SampleMap::Negate() {
42 for (auto& entry : sample_counts_)
Alexei Svitkine (slow) 2015/12/04 18:30:11 Nit: const auto&
bcwhite 2015/12/08 17:32:18 Can't be "const" because it's being changed.
43 entry.second = -entry.second;
44 }
45
41 scoped_ptr<SampleCountIterator> SampleMap::Iterator() const { 46 scoped_ptr<SampleCountIterator> SampleMap::Iterator() const {
42 return scoped_ptr<SampleCountIterator>(new SampleMapIterator(sample_counts_)); 47 return scoped_ptr<SampleCountIterator>(new SampleMapIterator(sample_counts_));
43 } 48 }
44 49
45 bool SampleMap::AddSubtractImpl(SampleCountIterator* iter, 50 bool SampleMap::AddSubtractImpl(SampleCountIterator* iter,
46 HistogramSamples::Operator op) { 51 HistogramSamples::Operator op) {
47 Sample min; 52 Sample min;
48 Sample max; 53 Sample max;
49 Count count; 54 Count count;
50 for (; !iter->Done(); iter->Next()) { 55 for (; !iter->Done(); iter->Next()) {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 *count = iter_->second; 90 *count = iter_->second;
86 } 91 }
87 92
88 void SampleMapIterator::SkipEmptyBuckets() { 93 void SampleMapIterator::SkipEmptyBuckets() {
89 while (!Done() && iter_->second == 0) { 94 while (!Done() && iter_->second == 0) {
90 ++iter_; 95 ++iter_;
91 } 96 }
92 } 97 }
93 98
94 } // namespace base 99 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698