| 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/statistics_recorder.h" | 5 #include "base/metrics/statistics_recorder.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 DCHECK(!statistics_recorder_); | 70 DCHECK(!statistics_recorder_); |
| 71 StatisticsRecorder::UninitializeForTesting(); | 71 StatisticsRecorder::UninitializeForTesting(); |
| 72 statistics_recorder_ = StatisticsRecorder::CreateTemporaryForTesting(); | 72 statistics_recorder_ = StatisticsRecorder::CreateTemporaryForTesting(); |
| 73 } | 73 } |
| 74 | 74 |
| 75 void UninitializeStatisticsRecorder() { | 75 void UninitializeStatisticsRecorder() { |
| 76 statistics_recorder_.reset(); | 76 statistics_recorder_.reset(); |
| 77 StatisticsRecorder::UninitializeForTesting(); | 77 StatisticsRecorder::UninitializeForTesting(); |
| 78 } | 78 } |
| 79 | 79 |
| 80 Histogram* CreateHistogram(const std::string& name, | 80 Histogram* CreateHistogram(const char* name, |
| 81 HistogramBase::Sample min, | 81 HistogramBase::Sample min, |
| 82 HistogramBase::Sample max, | 82 HistogramBase::Sample max, |
| 83 size_t bucket_count) { | 83 size_t bucket_count) { |
| 84 BucketRanges* ranges = new BucketRanges(bucket_count + 1); | 84 BucketRanges* ranges = new BucketRanges(bucket_count + 1); |
| 85 Histogram::InitializeBucketRanges(min, max, ranges); | 85 Histogram::InitializeBucketRanges(min, max, ranges); |
| 86 const BucketRanges* registered_ranges = | 86 const BucketRanges* registered_ranges = |
| 87 StatisticsRecorder::RegisterOrDeleteDuplicateRanges(ranges); | 87 StatisticsRecorder::RegisterOrDeleteDuplicateRanges(ranges); |
| 88 return new Histogram(name, min, max, registered_ranges); | 88 return new Histogram(name, min, max, registered_ranges); |
| 89 } | 89 } |
| 90 | 90 |
| (...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 709 histogram->Add(3); | 709 histogram->Add(3); |
| 710 histogram->Add(5); | 710 histogram->Add(5); |
| 711 StatisticsRecorder::ImportProvidedHistograms(); | 711 StatisticsRecorder::ImportProvidedHistograms(); |
| 712 snapshot = found->SnapshotSamples(); | 712 snapshot = found->SnapshotSamples(); |
| 713 EXPECT_EQ(3, snapshot->TotalCount()); | 713 EXPECT_EQ(3, snapshot->TotalCount()); |
| 714 EXPECT_EQ(2, snapshot->GetCount(3)); | 714 EXPECT_EQ(2, snapshot->GetCount(3)); |
| 715 EXPECT_EQ(1, snapshot->GetCount(5)); | 715 EXPECT_EQ(1, snapshot->GetCount(5)); |
| 716 } | 716 } |
| 717 | 717 |
| 718 } // namespace base | 718 } // namespace base |
| OLD | NEW |