OLD | NEW |
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 25 matching lines...) Expand all Loading... |
36 CHECK_LE(bucket_ranges_->bucket_count(), counts_size_); | 36 CHECK_LE(bucket_ranges_->bucket_count(), counts_size_); |
37 CHECK_GE(bucket_ranges_->bucket_count(), 1u); | 37 CHECK_GE(bucket_ranges_->bucket_count(), 1u); |
38 } | 38 } |
39 | 39 |
40 SampleVector::~SampleVector() {} | 40 SampleVector::~SampleVector() {} |
41 | 41 |
42 void SampleVector::Accumulate(Sample value, Count count) { | 42 void SampleVector::Accumulate(Sample value, Count count) { |
43 size_t bucket_index = GetBucketIndex(value); | 43 size_t bucket_index = GetBucketIndex(value); |
44 subtle::NoBarrier_Store(&counts_[bucket_index], | 44 subtle::NoBarrier_Store(&counts_[bucket_index], |
45 subtle::NoBarrier_Load(&counts_[bucket_index]) + count); | 45 subtle::NoBarrier_Load(&counts_[bucket_index]) + count); |
46 IncreaseSum(count * value); | 46 IncreaseSum(static_cast<int64_t>(count) * value); |
47 IncreaseRedundantCount(count); | 47 IncreaseRedundantCount(count); |
48 } | 48 } |
49 | 49 |
50 Count SampleVector::GetCount(Sample value) const { | 50 Count SampleVector::GetCount(Sample value) const { |
51 size_t bucket_index = GetBucketIndex(value); | 51 size_t bucket_index = GetBucketIndex(value); |
52 return subtle::NoBarrier_Load(&counts_[bucket_index]); | 52 return subtle::NoBarrier_Load(&counts_[bucket_index]); |
53 } | 53 } |
54 | 54 |
55 Count SampleVector::TotalCount() const { | 55 Count SampleVector::TotalCount() const { |
56 Count count = 0; | 56 Count count = 0; |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 return; | 187 return; |
188 | 188 |
189 while (index_ < counts_size_) { | 189 while (index_ < counts_size_) { |
190 if (subtle::NoBarrier_Load(&counts_[index_]) != 0) | 190 if (subtle::NoBarrier_Load(&counts_[index_]) != 0) |
191 return; | 191 return; |
192 index_++; | 192 index_++; |
193 } | 193 } |
194 } | 194 } |
195 | 195 |
196 } // namespace base | 196 } // namespace base |
OLD | NEW |