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/bucket_ranges.h" | 8 #include "base/metrics/bucket_ranges.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/metrics/sample_vector.h" | 10 #include "base/metrics/sample_vector.h" |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 EXPECT_EQ(600, samples1.sum()); | 84 EXPECT_EQ(600, samples1.sum()); |
85 EXPECT_EQ(300, samples1.TotalCount()); | 85 EXPECT_EQ(300, samples1.TotalCount()); |
86 EXPECT_EQ(samples1.redundant_count(), samples1.TotalCount()); | 86 EXPECT_EQ(samples1.redundant_count(), samples1.TotalCount()); |
87 } | 87 } |
88 | 88 |
89 #if (!defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)) && GTEST_HAS_DEATH_TEST | 89 #if (!defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)) && GTEST_HAS_DEATH_TEST |
90 TEST(SampleVectorDeathTest, BucketIndexTest) { | 90 TEST(SampleVectorDeathTest, BucketIndexTest) { |
91 // 8 buckets with exponential layout: | 91 // 8 buckets with exponential layout: |
92 // [0, 1) [1, 2) [2, 4) [4, 8) [8, 16) [16, 32) [32, 64) [64, INT_MAX) | 92 // [0, 1) [1, 2) [2, 4) [4, 8) [8, 16) [16, 32) [32, 64) [64, INT_MAX) |
93 BucketRanges ranges(9); | 93 BucketRanges ranges(9); |
94 Histogram::InitializeBucketRanges(1, 64, 8, &ranges); | 94 Histogram::InitializeBucketRanges(1, 64, &ranges); |
95 SampleVector samples(&ranges); | 95 SampleVector samples(&ranges); |
96 | 96 |
97 // Normal case | 97 // Normal case |
98 samples.Accumulate(0, 1); | 98 samples.Accumulate(0, 1); |
99 samples.Accumulate(3, 2); | 99 samples.Accumulate(3, 2); |
100 samples.Accumulate(64, 3); | 100 samples.Accumulate(64, 3); |
101 EXPECT_EQ(1, samples.GetCount(0)); | 101 EXPECT_EQ(1, samples.GetCount(0)); |
102 EXPECT_EQ(2, samples.GetCount(2)); | 102 EXPECT_EQ(2, samples.GetCount(2)); |
103 EXPECT_EQ(3, samples.GetCount(65)); | 103 EXPECT_EQ(3, samples.GetCount(65)); |
104 | 104 |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 samples.Accumulate(2, 100); | 256 samples.Accumulate(2, 100); |
257 it = samples.Iterator(); | 257 it = samples.Iterator(); |
258 EXPECT_FALSE(it->Done()); | 258 EXPECT_FALSE(it->Done()); |
259 } | 259 } |
260 | 260 |
261 #endif | 261 #endif |
262 // (!defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)) && GTEST_HAS_DEATH_TEST | 262 // (!defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)) && GTEST_HAS_DEATH_TEST |
263 | 263 |
264 } // namespace | 264 } // namespace |
265 } // namespace base | 265 } // namespace base |
OLD | NEW |