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

Side by Side Diff: base/test/histogram_tester.cc

Issue 1001833005: Update from https://crrev.com/320343 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Supress Created 5 years, 9 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/test/histogram_tester.h ('k') | base/test/mock_devices_changed_observer.h » ('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 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/test/histogram_tester.h" 5 #include "base/test/histogram_tester.h"
6 6
7 #include "base/metrics/histogram.h" 7 #include "base/metrics/histogram.h"
8 #include "base/metrics/histogram_samples.h" 8 #include "base/metrics/histogram_samples.h"
9 #include "base/metrics/statistics_recorder.h" 9 #include "base/metrics/statistics_recorder.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 histograms_snapshot_[histogram_name]; 83 histograms_snapshot_[histogram_name];
84 if (named_original_samples) 84 if (named_original_samples)
85 named_samples->Subtract(*named_original_samples); 85 named_samples->Subtract(*named_original_samples);
86 return named_samples.Pass(); 86 return named_samples.Pass();
87 } 87 }
88 88
89 void HistogramTester::CheckBucketCount( 89 void HistogramTester::CheckBucketCount(
90 const std::string& name, 90 const std::string& name,
91 base::HistogramBase::Sample sample, 91 base::HistogramBase::Sample sample,
92 base::HistogramBase::Count expected_count, 92 base::HistogramBase::Count expected_count,
93 base::HistogramSamples& samples) const { 93 const base::HistogramSamples& samples) const {
94 int actual_count = samples.GetCount(sample); 94 int actual_count = samples.GetCount(sample);
95 std::map<std::string, HistogramSamples*>::const_iterator histogram_data; 95 std::map<std::string, HistogramSamples*>::const_iterator histogram_data;
96 histogram_data = histograms_snapshot_.find(name); 96 histogram_data = histograms_snapshot_.find(name);
97 if (histogram_data != histograms_snapshot_.end()) 97 if (histogram_data != histograms_snapshot_.end())
98 actual_count -= histogram_data->second->GetCount(sample); 98 actual_count -= histogram_data->second->GetCount(sample);
99 99
100 EXPECT_EQ(expected_count, actual_count) 100 EXPECT_EQ(expected_count, actual_count)
101 << "Histogram \"" << name 101 << "Histogram \"" << name
102 << "\" does not have the right number of samples (" << expected_count 102 << "\" does not have the right number of samples (" << expected_count
103 << ") in the expected bucket (" << sample << "). It has (" << actual_count 103 << ") in the expected bucket (" << sample << "). It has (" << actual_count
104 << ")."; 104 << ").";
105 } 105 }
106 106
107 void HistogramTester::CheckTotalCount(const std::string& name, 107 void HistogramTester::CheckTotalCount(
108 base::HistogramBase::Count expected_count, 108 const std::string& name,
109 base::HistogramSamples& samples) const { 109 base::HistogramBase::Count expected_count,
110 const base::HistogramSamples& samples) const {
110 int actual_count = samples.TotalCount(); 111 int actual_count = samples.TotalCount();
111 std::map<std::string, HistogramSamples*>::const_iterator histogram_data; 112 std::map<std::string, HistogramSamples*>::const_iterator histogram_data;
112 histogram_data = histograms_snapshot_.find(name); 113 histogram_data = histograms_snapshot_.find(name);
113 if (histogram_data != histograms_snapshot_.end()) 114 if (histogram_data != histograms_snapshot_.end())
114 actual_count -= histogram_data->second->TotalCount(); 115 actual_count -= histogram_data->second->TotalCount();
115 116
116 EXPECT_EQ(expected_count, actual_count) 117 EXPECT_EQ(expected_count, actual_count)
117 << "Histogram \"" << name 118 << "Histogram \"" << name
118 << "\" does not have the right total number of samples (" 119 << "\" does not have the right total number of samples ("
119 << expected_count << "). It has (" << actual_count << ")."; 120 << expected_count << "). It has (" << actual_count << ").";
120 } 121 }
121 122
122 } // namespace base 123 } // namespace base
OLDNEW
« no previous file with comments | « base/test/histogram_tester.h ('k') | base/test/mock_devices_changed_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698