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/sparse_histogram.h" | 5 #include "base/metrics/sparse_histogram.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/metrics/histogram_base.h" | 10 #include "base/metrics/histogram_base.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 | 53 |
54 void UninitializeStatisticsRecorder() { | 54 void UninitializeStatisticsRecorder() { |
55 delete statistics_recorder_; | 55 delete statistics_recorder_; |
56 statistics_recorder_ = NULL; | 56 statistics_recorder_ = NULL; |
57 } | 57 } |
58 | 58 |
59 void CreatePersistentMemoryAllocator() { | 59 void CreatePersistentMemoryAllocator() { |
60 // By getting the results-histogram before any persistent allocator | 60 // By getting the results-histogram before any persistent allocator |
61 // is attached, that histogram is guaranteed not to be stored in | 61 // is attached, that histogram is guaranteed not to be stored in |
62 // any persistent memory segment (which simplifies some tests). | 62 // any persistent memory segment (which simplifies some tests). |
63 PersistentHistogramAllocator::GetCreateHistogramResultHistogram(); | 63 GlobalHistogramAllocator::GetCreateHistogramResultHistogram(); |
64 | 64 |
65 PersistentHistogramAllocator::CreateGlobalAllocatorOnLocalMemory( | 65 GlobalHistogramAllocator::CreateWithLocalMemory( |
66 kAllocatorMemorySize, 0, "SparseHistogramAllocatorTest"); | 66 kAllocatorMemorySize, 0, "SparseHistogramAllocatorTest"); |
67 allocator_ = | 67 allocator_ = GlobalHistogramAllocator::Get()->memory_allocator(); |
68 PersistentHistogramAllocator::GetGlobalAllocator()->memory_allocator(); | |
69 } | 68 } |
70 | 69 |
71 void DestroyPersistentMemoryAllocator() { | 70 void DestroyPersistentMemoryAllocator() { |
72 allocator_ = nullptr; | 71 allocator_ = nullptr; |
73 PersistentHistogramAllocator::ReleaseGlobalAllocatorForTesting(); | 72 GlobalHistogramAllocator::ReleaseForTesting(); |
74 } | 73 } |
75 | 74 |
76 std::unique_ptr<SparseHistogram> NewSparseHistogram(const std::string& name) { | 75 std::unique_ptr<SparseHistogram> NewSparseHistogram(const std::string& name) { |
77 return std::unique_ptr<SparseHistogram>(new SparseHistogram(name)); | 76 return std::unique_ptr<SparseHistogram>(new SparseHistogram(name)); |
78 } | 77 } |
79 | 78 |
80 const bool use_persistent_histogram_allocator_; | 79 const bool use_persistent_histogram_allocator_; |
81 | 80 |
82 StatisticsRecorder* statistics_recorder_; | 81 StatisticsRecorder* statistics_recorder_; |
83 std::unique_ptr<char[]> allocator_memory_; | |
84 PersistentMemoryAllocator* allocator_ = nullptr; | 82 PersistentMemoryAllocator* allocator_ = nullptr; |
85 | 83 |
86 private: | 84 private: |
87 DISALLOW_COPY_AND_ASSIGN(SparseHistogramTest); | 85 DISALLOW_COPY_AND_ASSIGN(SparseHistogramTest); |
88 }; | 86 }; |
89 | 87 |
90 // Run all HistogramTest cases with both heap and persistent memory. | 88 // Run all HistogramTest cases with both heap and persistent memory. |
91 INSTANTIATE_TEST_CASE_P(HeapAndPersistent, | 89 INSTANTIATE_TEST_CASE_P(HeapAndPersistent, |
92 SparseHistogramTest, | 90 SparseHistogramTest, |
93 testing::Bool()); | 91 testing::Bool()); |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 TimeDelta add_ticks = TimeTicks::Now() - add_start; | 272 TimeDelta add_ticks = TimeTicks::Now() - add_start; |
275 int64_t add_ms = add_ticks.InMilliseconds(); | 273 int64_t add_ms = add_ticks.InMilliseconds(); |
276 | 274 |
277 VLOG(1) << kTestAddCount << " histogram adds took " << add_ms | 275 VLOG(1) << kTestAddCount << " histogram adds took " << add_ms |
278 << "ms or about " | 276 << "ms or about " |
279 << (add_ms * 1000000) / kTestAddCount | 277 << (add_ms * 1000000) / kTestAddCount |
280 << "ns each."; | 278 << "ns each."; |
281 } | 279 } |
282 | 280 |
283 } // namespace base | 281 } // namespace base |
OLD | NEW |