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_map.h" | 5 #include "base/metrics/sample_map.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 | 10 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 } // namespace | 77 } // namespace |
78 | 78 |
79 SampleMap::SampleMap() : SampleMap(0) {} | 79 SampleMap::SampleMap() : SampleMap(0) {} |
80 | 80 |
81 SampleMap::SampleMap(uint64_t id) : HistogramSamples(id) {} | 81 SampleMap::SampleMap(uint64_t id) : HistogramSamples(id) {} |
82 | 82 |
83 SampleMap::~SampleMap() {} | 83 SampleMap::~SampleMap() {} |
84 | 84 |
85 void SampleMap::Accumulate(Sample value, Count count) { | 85 void SampleMap::Accumulate(Sample value, Count count) { |
86 sample_counts_[value] += count; | 86 sample_counts_[value] += count; |
87 IncreaseSumAndCount(static_cast<int64_t>(count) * value, count); | 87 IncreaseSum(static_cast<int64_t>(count) * value); |
| 88 IncreaseRedundantCount(count); |
88 } | 89 } |
89 | 90 |
90 Count SampleMap::GetCount(Sample value) const { | 91 Count SampleMap::GetCount(Sample value) const { |
91 std::map<Sample, Count>::const_iterator it = sample_counts_.find(value); | 92 std::map<Sample, Count>::const_iterator it = sample_counts_.find(value); |
92 if (it == sample_counts_.end()) | 93 if (it == sample_counts_.end()) |
93 return 0; | 94 return 0; |
94 return it->second; | 95 return it->second; |
95 } | 96 } |
96 | 97 |
97 Count SampleMap::TotalCount() const { | 98 Count SampleMap::TotalCount() const { |
(...skipping 16 matching lines...) Expand all Loading... |
114 iter->Get(&min, &max, &count); | 115 iter->Get(&min, &max, &count); |
115 if (min + 1 != max) | 116 if (min + 1 != max) |
116 return false; // SparseHistogram only supports bucket with size 1. | 117 return false; // SparseHistogram only supports bucket with size 1. |
117 | 118 |
118 sample_counts_[min] += (op == HistogramSamples::ADD) ? count : -count; | 119 sample_counts_[min] += (op == HistogramSamples::ADD) ? count : -count; |
119 } | 120 } |
120 return true; | 121 return true; |
121 } | 122 } |
122 | 123 |
123 } // namespace base | 124 } // namespace base |
OLD | NEW |