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

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

Issue 484603006: Add LOCAL_ prefix to non-UMA histogram macros. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments. Created 6 years, 4 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
« no previous file with comments | « base/metrics/sparse_histogram.h ('k') | base/metrics/statistics_recorder_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <string> 5 #include <string>
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/metrics/histogram_base.h" 8 #include "base/metrics/histogram_base.h"
9 #include "base/metrics/histogram_samples.h" 9 #include "base/metrics/histogram_samples.h"
10 #include "base/metrics/sample_map.h" 10 #include "base/metrics/sample_map.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 57
58 histogram->Add(100); 58 histogram->Add(100);
59 histogram->Add(101); 59 histogram->Add(101);
60 scoped_ptr<HistogramSamples> snapshot2(histogram->SnapshotSamples()); 60 scoped_ptr<HistogramSamples> snapshot2(histogram->SnapshotSamples());
61 EXPECT_EQ(3, snapshot2->TotalCount()); 61 EXPECT_EQ(3, snapshot2->TotalCount());
62 EXPECT_EQ(2, snapshot2->GetCount(100)); 62 EXPECT_EQ(2, snapshot2->GetCount(100));
63 EXPECT_EQ(1, snapshot2->GetCount(101)); 63 EXPECT_EQ(1, snapshot2->GetCount(101));
64 } 64 }
65 65
66 TEST_F(SparseHistogramTest, MacroBasicTest) { 66 TEST_F(SparseHistogramTest, MacroBasicTest) {
67 HISTOGRAM_SPARSE_SLOWLY("Sparse", 100); 67 UMA_HISTOGRAM_SPARSE_SLOWLY("Sparse", 100);
68 HISTOGRAM_SPARSE_SLOWLY("Sparse", 200); 68 UMA_HISTOGRAM_SPARSE_SLOWLY("Sparse", 200);
69 HISTOGRAM_SPARSE_SLOWLY("Sparse", 100); 69 UMA_HISTOGRAM_SPARSE_SLOWLY("Sparse", 100);
70 70
71 StatisticsRecorder::Histograms histograms; 71 StatisticsRecorder::Histograms histograms;
72 StatisticsRecorder::GetHistograms(&histograms); 72 StatisticsRecorder::GetHistograms(&histograms);
73 73
74 ASSERT_EQ(1U, histograms.size()); 74 ASSERT_EQ(1U, histograms.size());
75 HistogramBase* sparse_histogram = histograms[0]; 75 HistogramBase* sparse_histogram = histograms[0];
76 76
77 EXPECT_EQ(SPARSE_HISTOGRAM, sparse_histogram->GetHistogramType()); 77 EXPECT_EQ(SPARSE_HISTOGRAM, sparse_histogram->GetHistogramType());
78 EXPECT_EQ("Sparse", sparse_histogram->histogram_name()); 78 EXPECT_EQ("Sparse", sparse_histogram->histogram_name());
79 EXPECT_EQ(HistogramBase::kNoFlags, sparse_histogram->flags()); 79 EXPECT_EQ(HistogramBase::kUmaTargetedHistogramFlag,
80 sparse_histogram->flags());
80 81
81 scoped_ptr<HistogramSamples> samples = sparse_histogram->SnapshotSamples(); 82 scoped_ptr<HistogramSamples> samples = sparse_histogram->SnapshotSamples();
82 EXPECT_EQ(3, samples->TotalCount()); 83 EXPECT_EQ(3, samples->TotalCount());
83 EXPECT_EQ(2, samples->GetCount(100)); 84 EXPECT_EQ(2, samples->GetCount(100));
84 EXPECT_EQ(1, samples->GetCount(200)); 85 EXPECT_EQ(1, samples->GetCount(200));
85 } 86 }
86 87
87 TEST_F(SparseHistogramTest, MacroUmaTest) {
88 UMA_HISTOGRAM_SPARSE_SLOWLY("Uma", 100);
89
90 StatisticsRecorder::Histograms histograms;
91 StatisticsRecorder::GetHistograms(&histograms);
92
93 ASSERT_EQ(1U, histograms.size());
94 HistogramBase* sparse_histogram = histograms[0];
95
96 EXPECT_EQ("Uma", sparse_histogram->histogram_name());
97 EXPECT_EQ(HistogramBase::kUmaTargetedHistogramFlag,
98 sparse_histogram->flags());
99 }
100
101 TEST_F(SparseHistogramTest, MacroInLoopTest) { 88 TEST_F(SparseHistogramTest, MacroInLoopTest) {
102 // Unlike the macros in histogram.h, SparseHistogram macros can have a 89 // Unlike the macros in histogram.h, SparseHistogram macros can have a
103 // variable as histogram name. 90 // variable as histogram name.
104 for (int i = 0; i < 2; i++) { 91 for (int i = 0; i < 2; i++) {
105 std::string name = StringPrintf("Sparse%d", i + 1); 92 std::string name = StringPrintf("Sparse%d", i + 1);
106 UMA_HISTOGRAM_SPARSE_SLOWLY(name, 100); 93 UMA_HISTOGRAM_SPARSE_SLOWLY(name, 100);
107 } 94 }
108 95
109 StatisticsRecorder::Histograms histograms; 96 StatisticsRecorder::Histograms histograms;
110 StatisticsRecorder::GetHistograms(&histograms); 97 StatisticsRecorder::GetHistograms(&histograms);
(...skipping 24 matching lines...) Expand all
135 122
136 int flag; 123 int flag;
137 EXPECT_TRUE(iter.ReadInt(&flag)); 124 EXPECT_TRUE(iter.ReadInt(&flag));
138 EXPECT_EQ(HistogramBase::kIPCSerializationSourceFlag, flag); 125 EXPECT_EQ(HistogramBase::kIPCSerializationSourceFlag, flag);
139 126
140 // No more data in the pickle. 127 // No more data in the pickle.
141 EXPECT_FALSE(iter.SkipBytes(1)); 128 EXPECT_FALSE(iter.SkipBytes(1));
142 } 129 }
143 130
144 } // namespace base 131 } // namespace base
OLDNEW
« no previous file with comments | « base/metrics/sparse_histogram.h ('k') | base/metrics/statistics_recorder_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698