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

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

Issue 1425533011: Support "shared" histograms between processes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@shmem-alloc
Patch Set: added a couple tests (and fixed related issues) Created 5 years 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_snapshot_manager.h" 5 #include "base/metrics/histogram_snapshot_manager.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/metrics/histogram_delta_serialization.h" 10 #include "base/metrics/histogram_delta_serialization.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 StatisticsRecorder statistics_recorder_; 56 StatisticsRecorder statistics_recorder_;
57 HistogramFlattenerDeltaRecorder histogram_flattener_delta_recorder_; 57 HistogramFlattenerDeltaRecorder histogram_flattener_delta_recorder_;
58 HistogramSnapshotManager histogram_snapshot_manager_; 58 HistogramSnapshotManager histogram_snapshot_manager_;
59 }; 59 };
60 60
61 TEST_F(HistogramSnapshotManagerTest, PrepareDeltasNoFlagsFilter) { 61 TEST_F(HistogramSnapshotManagerTest, PrepareDeltasNoFlagsFilter) {
62 // kNoFlags filter should record all histograms. 62 // kNoFlags filter should record all histograms.
63 UMA_HISTOGRAM_ENUMERATION("UmaHistogram", 1, 2); 63 UMA_HISTOGRAM_ENUMERATION("UmaHistogram", 1, 2);
64 UMA_STABILITY_HISTOGRAM_ENUMERATION("UmaStabilityHistogram", 1, 2); 64 UMA_STABILITY_HISTOGRAM_ENUMERATION("UmaStabilityHistogram", 1, 2);
65 65
66 histogram_snapshot_manager_.PrepareDeltas(HistogramBase::kNoFlags, 66 histogram_snapshot_manager_.PrepareDeltas(
67 HistogramBase::kNoFlags); 67 StatisticsRecorder::begin(false), StatisticsRecorder::end(),
68 HistogramBase::kNoFlags, HistogramBase::kNoFlags);
68 69
69 const std::vector<std::string>& histograms = 70 const std::vector<std::string>& histograms =
70 histogram_flattener_delta_recorder_.GetRecordedDeltaHistogramNames(); 71 histogram_flattener_delta_recorder_.GetRecordedDeltaHistogramNames();
71 EXPECT_EQ(2U, histograms.size()); 72 EXPECT_EQ(2U, histograms.size());
72 EXPECT_EQ("UmaHistogram", histograms[0]); 73 EXPECT_EQ("UmaHistogram", histograms[0]);
73 EXPECT_EQ("UmaStabilityHistogram", histograms[1]); 74 EXPECT_EQ("UmaStabilityHistogram", histograms[1]);
74 } 75 }
75 76
76 TEST_F(HistogramSnapshotManagerTest, PrepareDeltasUmaHistogramFlagFilter) { 77 TEST_F(HistogramSnapshotManagerTest, PrepareDeltasUmaHistogramFlagFilter) {
77 // Note that kUmaStabilityHistogramFlag includes kUmaTargetedHistogramFlag. 78 // Note that kUmaStabilityHistogramFlag includes kUmaTargetedHistogramFlag.
78 UMA_HISTOGRAM_ENUMERATION("UmaHistogram", 1, 2); 79 UMA_HISTOGRAM_ENUMERATION("UmaHistogram", 1, 2);
79 UMA_STABILITY_HISTOGRAM_ENUMERATION("UmaStabilityHistogram", 1, 2); 80 UMA_STABILITY_HISTOGRAM_ENUMERATION("UmaStabilityHistogram", 1, 2);
80 81
81 histogram_snapshot_manager_.PrepareDeltas( 82 histogram_snapshot_manager_.PrepareDeltas(
83 StatisticsRecorder::begin(false), StatisticsRecorder::end(),
82 HistogramBase::kNoFlags, HistogramBase::kUmaTargetedHistogramFlag); 84 HistogramBase::kNoFlags, HistogramBase::kUmaTargetedHistogramFlag);
83 85
84 const std::vector<std::string>& histograms = 86 const std::vector<std::string>& histograms =
85 histogram_flattener_delta_recorder_.GetRecordedDeltaHistogramNames(); 87 histogram_flattener_delta_recorder_.GetRecordedDeltaHistogramNames();
86 EXPECT_EQ(2U, histograms.size()); 88 EXPECT_EQ(2U, histograms.size());
87 EXPECT_EQ("UmaHistogram", histograms[0]); 89 EXPECT_EQ("UmaHistogram", histograms[0]);
88 EXPECT_EQ("UmaStabilityHistogram", histograms[1]); 90 EXPECT_EQ("UmaStabilityHistogram", histograms[1]);
89 } 91 }
90 92
91 TEST_F(HistogramSnapshotManagerTest, 93 TEST_F(HistogramSnapshotManagerTest,
92 PrepareDeltasUmaStabilityHistogramFlagFilter) { 94 PrepareDeltasUmaStabilityHistogramFlagFilter) {
93 UMA_HISTOGRAM_ENUMERATION("UmaHistogram", 1, 2); 95 UMA_HISTOGRAM_ENUMERATION("UmaHistogram", 1, 2);
94 UMA_STABILITY_HISTOGRAM_ENUMERATION("UmaStabilityHistogram", 1, 2); 96 UMA_STABILITY_HISTOGRAM_ENUMERATION("UmaStabilityHistogram", 1, 2);
95 97
96 histogram_snapshot_manager_.PrepareDeltas( 98 histogram_snapshot_manager_.PrepareDeltas(
99 StatisticsRecorder::begin(false), StatisticsRecorder::end(),
97 HistogramBase::kNoFlags, HistogramBase::kUmaStabilityHistogramFlag); 100 HistogramBase::kNoFlags, HistogramBase::kUmaStabilityHistogramFlag);
98 101
99 const std::vector<std::string>& histograms = 102 const std::vector<std::string>& histograms =
100 histogram_flattener_delta_recorder_.GetRecordedDeltaHistogramNames(); 103 histogram_flattener_delta_recorder_.GetRecordedDeltaHistogramNames();
101 EXPECT_EQ(1U, histograms.size()); 104 EXPECT_EQ(1U, histograms.size());
102 EXPECT_EQ("UmaStabilityHistogram", histograms[0]); 105 EXPECT_EQ("UmaStabilityHistogram", histograms[0]);
103 } 106 }
104 107
105 } // namespace base 108 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698