Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(510)

Side by Side Diff: base/metrics/histogram_unittest.cc

Issue 1734033003: Add support for persistent sparse histograms. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: some 'git cl format' changes and other cosmetic improvements Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/histogram.h" 5 #include "base/metrics/histogram.h"
6 6
7 #include <limits.h> 7 #include <limits.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 19 matching lines...) Expand all
30 // Test parameter indicates if a persistent memory allocator should be used 30 // Test parameter indicates if a persistent memory allocator should be used
31 // for histogram allocation. False will allocate histograms from the process 31 // for histogram allocation. False will allocate histograms from the process
32 // heap. 32 // heap.
33 class HistogramTest : public testing::TestWithParam<bool> { 33 class HistogramTest : public testing::TestWithParam<bool> {
34 protected: 34 protected:
35 const int32_t kAllocatorMemorySize = 8 << 20; // 8 MiB 35 const int32_t kAllocatorMemorySize = 8 << 20; // 8 MiB
36 36
37 HistogramTest() : use_persistent_histogram_allocator_(GetParam()) {} 37 HistogramTest() : use_persistent_histogram_allocator_(GetParam()) {}
38 38
39 void SetUp() override { 39 void SetUp() override {
40 if (use_persistent_histogram_allocator_)
41 CreatePersistentMemoryAllocator();
42
40 // Each test will have a clean state (no Histogram / BucketRanges 43 // Each test will have a clean state (no Histogram / BucketRanges
41 // registered). 44 // registered).
42 InitializeStatisticsRecorder(); 45 InitializeStatisticsRecorder();
43 if (use_persistent_histogram_allocator_)
44 CreatePersistentMemoryAllocator();
45 } 46 }
46 47
47 void TearDown() override { 48 void TearDown() override {
48 if (allocator_) { 49 if (allocator_) {
49 ASSERT_FALSE(allocator_->IsFull()); 50 ASSERT_FALSE(allocator_->IsFull());
50 ASSERT_FALSE(allocator_->IsCorrupt()); 51 ASSERT_FALSE(allocator_->IsCorrupt());
51 } 52 }
52 UninitializeStatisticsRecorder(); 53 UninitializeStatisticsRecorder();
53 DestroyPersistentMemoryAllocator(); 54 DestroyPersistentMemoryAllocator();
54 } 55 }
(...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after
797 // CustomHistogram needs at least 1 valid range. 798 // CustomHistogram needs at least 1 valid range.
798 custom_ranges.clear(); 799 custom_ranges.clear();
799 custom_ranges.push_back(0); 800 custom_ranges.push_back(0);
800 EXPECT_DEATH(CustomHistogram::FactoryGet("BadRangesCustom3", custom_ranges, 801 EXPECT_DEATH(CustomHistogram::FactoryGet("BadRangesCustom3", custom_ranges,
801 HistogramBase::kNoFlags), 802 HistogramBase::kNoFlags),
802 ""); 803 "");
803 } 804 }
804 #endif 805 #endif
805 806
806 } // namespace base 807 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698