| 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 30 matching lines...) Expand all Loading... |
| 41 if (allocator_) { | 41 if (allocator_) { |
| 42 ASSERT_FALSE(allocator_->IsFull()); | 42 ASSERT_FALSE(allocator_->IsFull()); |
| 43 ASSERT_FALSE(allocator_->IsCorrupt()); | 43 ASSERT_FALSE(allocator_->IsCorrupt()); |
| 44 } | 44 } |
| 45 UninitializeStatisticsRecorder(); | 45 UninitializeStatisticsRecorder(); |
| 46 DestroyPersistentMemoryAllocator(); | 46 DestroyPersistentMemoryAllocator(); |
| 47 } | 47 } |
| 48 | 48 |
| 49 void InitializeStatisticsRecorder() { | 49 void InitializeStatisticsRecorder() { |
| 50 DCHECK(!statistics_recorder_); | 50 DCHECK(!statistics_recorder_); |
| 51 statistics_recorder_.reset(new StatisticsRecorder()); | 51 statistics_recorder_ = StatisticsRecorder::CreateTemporaryForTesting(); |
| 52 } | 52 } |
| 53 | 53 |
| 54 void UninitializeStatisticsRecorder() { | 54 void UninitializeStatisticsRecorder() { |
| 55 statistics_recorder_.reset(); | 55 statistics_recorder_.reset(); |
| 56 } | 56 } |
| 57 | 57 |
| 58 void CreatePersistentMemoryAllocator() { | 58 void CreatePersistentMemoryAllocator() { |
| 59 // By getting the results-histogram before any persistent allocator | 59 // By getting the results-histogram before any persistent allocator |
| 60 // is attached, that histogram is guaranteed not to be stored in | 60 // is attached, that histogram is guaranteed not to be stored in |
| 61 // any persistent memory segment (which simplifies some tests). | 61 // any persistent memory segment (which simplifies some tests). |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 TimeDelta add_ticks = TimeTicks::Now() - add_start; | 320 TimeDelta add_ticks = TimeTicks::Now() - add_start; |
| 321 int64_t add_ms = add_ticks.InMilliseconds(); | 321 int64_t add_ms = add_ticks.InMilliseconds(); |
| 322 | 322 |
| 323 VLOG(1) << kTestAddCount << " histogram adds took " << add_ms | 323 VLOG(1) << kTestAddCount << " histogram adds took " << add_ms |
| 324 << "ms or about " | 324 << "ms or about " |
| 325 << (add_ms * 1000000) / kTestAddCount | 325 << (add_ms * 1000000) / kTestAddCount |
| 326 << "ns each."; | 326 << "ns each."; |
| 327 } | 327 } |
| 328 | 328 |
| 329 } // namespace base | 329 } // namespace base |
| OLD | NEW |