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 <vector> | 5 #include <vector> |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/metrics/statistics_recorder.h" | 9 #include "base/metrics/statistics_recorder.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 18 matching lines...) Expand all Loading... | |
29 | 29 |
30 void UninitializeStatisticsRecorder() { | 30 void UninitializeStatisticsRecorder() { |
31 delete statistics_recorder_; | 31 delete statistics_recorder_; |
32 statistics_recorder_ = NULL; | 32 statistics_recorder_ = NULL; |
33 } | 33 } |
34 | 34 |
35 Histogram* CreateHistogram(const std::string& name, | 35 Histogram* CreateHistogram(const std::string& name, |
36 HistogramBase::Sample min, | 36 HistogramBase::Sample min, |
37 HistogramBase::Sample max, | 37 HistogramBase::Sample max, |
38 size_t bucket_count) { | 38 size_t bucket_count) { |
39 return new Histogram(name, min, max, bucket_count, NULL); | 39 BucketRanges* ranges = new BucketRanges(bucket_count + 1); |
40 const BucketRanges* registered_ranges = | |
41 StatisticsRecorder::RegisterOrDeleteDuplicateRanges(ranges); | |
jar (doing other things)
2013/06/20 16:41:18
This tries to de-dup a set of ranges that are full
Ilya Sherman
2013/06/21 04:03:05
Done.
| |
42 return new Histogram(name, min, max, registered_ranges); | |
40 } | 43 } |
41 | 44 |
42 void DeleteHistogram(HistogramBase* histogram) { | 45 void DeleteHistogram(HistogramBase* histogram) { |
43 delete histogram; | 46 delete histogram; |
44 } | 47 } |
45 | 48 |
46 StatisticsRecorder* statistics_recorder_; | 49 StatisticsRecorder* statistics_recorder_; |
47 }; | 50 }; |
48 | 51 |
49 TEST_F(StatisticsRecorderTest, NotInitialized) { | 52 TEST_F(StatisticsRecorderTest, NotInitialized) { |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
253 EXPECT_EQ(1u, ranges.size()); | 256 EXPECT_EQ(1u, ranges.size()); |
254 | 257 |
255 Histogram::FactoryGet("Histogram3", 1, 64, 16, HistogramBase::kNoFlags); | 258 Histogram::FactoryGet("Histogram3", 1, 64, 16, HistogramBase::kNoFlags); |
256 | 259 |
257 ranges.clear(); | 260 ranges.clear(); |
258 StatisticsRecorder::GetBucketRanges(&ranges); | 261 StatisticsRecorder::GetBucketRanges(&ranges); |
259 EXPECT_EQ(2u, ranges.size()); | 262 EXPECT_EQ(2u, ranges.size()); |
260 } | 263 } |
261 | 264 |
262 } // namespace base | 265 } // namespace base |
OLD | NEW |