| 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 | 8 |
| 9 using std::map; | 9 using std::map; |
| 10 | 10 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 ++it) { | 37 ++it) { |
| 38 count += it->second; | 38 count += it->second; |
| 39 } | 39 } |
| 40 return count; | 40 return count; |
| 41 } | 41 } |
| 42 | 42 |
| 43 scoped_ptr<SampleCountIterator> SampleMap::Iterator() const { | 43 scoped_ptr<SampleCountIterator> SampleMap::Iterator() const { |
| 44 return scoped_ptr<SampleCountIterator>(new SampleMapIterator(sample_counts_)); | 44 return scoped_ptr<SampleCountIterator>(new SampleMapIterator(sample_counts_)); |
| 45 } | 45 } |
| 46 | 46 |
| 47 void SampleMap::ResetRedundantCount(Count count) { | |
| 48 IncreaseRedundantCount(-redundant_count()); | |
| 49 IncreaseRedundantCount(count); | |
| 50 } | |
| 51 | |
| 52 bool SampleMap::AddSubtractImpl(SampleCountIterator* iter, | 47 bool SampleMap::AddSubtractImpl(SampleCountIterator* iter, |
| 53 HistogramSamples::Operator op) { | 48 HistogramSamples::Operator op) { |
| 54 Sample min; | 49 Sample min; |
| 55 Sample max; | 50 Sample max; |
| 56 Count count; | 51 Count count; |
| 57 for (; !iter->Done(); iter->Next()) { | 52 for (; !iter->Done(); iter->Next()) { |
| 58 iter->Get(&min, &max, &count); | 53 iter->Get(&min, &max, &count); |
| 59 if (min + 1 != max) | 54 if (min + 1 != max) |
| 60 return false; // SparseHistogram only supports bucket with size 1. | 55 return false; // SparseHistogram only supports bucket with size 1. |
| 61 sample_counts_[min] += (op == HistogramSamples::ADD) ? count : -count; | 56 sample_counts_[min] += (op == HistogramSamples::ADD) ? count : -count; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 82 DCHECK(!Done()); | 77 DCHECK(!Done()); |
| 83 if (min != NULL) | 78 if (min != NULL) |
| 84 *min = iter_->first; | 79 *min = iter_->first; |
| 85 if (max != NULL) | 80 if (max != NULL) |
| 86 *max = iter_->first + 1; | 81 *max = iter_->first + 1; |
| 87 if (count != NULL) | 82 if (count != NULL) |
| 88 *count = iter_->second; | 83 *count = iter_->second; |
| 89 } | 84 } |
| 90 | 85 |
| 91 } // namespace base | 86 } // namespace base |
| OLD | NEW |