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

Side by Side Diff: base/metrics/sample_vector.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_vector.h" 5 #include "base/metrics/sample_vector.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/metrics/bucket_ranges.h" 8 #include "base/metrics/bucket_ranges.h"
9 9
10 namespace base { 10 namespace base {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 } 59 }
60 60
61 Count SampleVector::TotalCount() const { 61 Count SampleVector::TotalCount() const {
62 Count count = 0; 62 Count count = 0;
63 for (size_t i = 0; i < counts_size_; i++) { 63 for (size_t i = 0; i < counts_size_; i++) {
64 count += subtle::NoBarrier_Load(&counts_[i]); 64 count += subtle::NoBarrier_Load(&counts_[i]);
65 } 65 }
66 return count; 66 return count;
67 } 67 }
68 68
69 void SampleVector::Negate() {
70 for (size_t i = 0; i < counts_size_; i++) {
71 subtle::NoBarrier_Store(&counts_[i],
72 -subtle::NoBarrier_Load(&counts_[i]));
73 }
74 }
75
69 Count SampleVector::GetCountAtIndex(size_t bucket_index) const { 76 Count SampleVector::GetCountAtIndex(size_t bucket_index) const {
70 DCHECK(bucket_index < counts_size_); 77 DCHECK(bucket_index < counts_size_);
71 return subtle::NoBarrier_Load(&counts_[bucket_index]); 78 return subtle::NoBarrier_Load(&counts_[bucket_index]);
72 } 79 }
73 80
74 scoped_ptr<SampleCountIterator> SampleVector::Iterator() const { 81 scoped_ptr<SampleCountIterator> SampleVector::Iterator() const {
75 return scoped_ptr<SampleCountIterator>( 82 return scoped_ptr<SampleCountIterator>(
76 new SampleVectorIterator(counts_, counts_size_, bucket_ranges_)); 83 new SampleVectorIterator(counts_, counts_size_, bucket_ranges_));
77 } 84 }
78 85
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 return; 200 return;
194 201
195 while (index_ < counts_size_) { 202 while (index_ < counts_size_) {
196 if (subtle::NoBarrier_Load(&counts_[index_]) != 0) 203 if (subtle::NoBarrier_Load(&counts_[index_]) != 0)
197 return; 204 return;
198 index_++; 205 index_++;
199 } 206 }
200 } 207 }
201 208
202 } // namespace base 209 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698