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

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

Issue 2036643004: Create ForTesting method rather than declaring a dozen "friend" classes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 4 years, 6 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/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
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
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
OLDNEW
« no previous file with comments | « base/metrics/persistent_histogram_allocator_unittest.cc ('k') | base/metrics/statistics_recorder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698