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

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

Issue 1177263004: Add HistogramTester::GetAllSamples. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add GetAllSamples() and test. Created 5 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
« no previous file with comments | « no previous file | base/test/histogram_tester.cc » ('j') | base/test/histogram_tester_unittest.cc » ('J')
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 #ifndef BASE_TEST_HISTOGRAM_TESTER_H_ 5 #ifndef BASE_TEST_HISTOGRAM_TESTER_H_
6 #define BASE_TEST_HISTOGRAM_TESTER_H_ 6 #define BASE_TEST_HISTOGRAM_TESTER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <utility>
11 #include <vector>
10 12
11 #include "base/basictypes.h" 13 #include "base/basictypes.h"
12 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
13 #include "base/metrics/histogram.h" 15 #include "base/metrics/histogram.h"
14 #include "base/metrics/histogram_base.h" 16 #include "base/metrics/histogram_base.h"
15 17
16 namespace base { 18 namespace base {
17 19
18 class HistogramSamples; 20 class HistogramSamples;
19 21
(...skipping 20 matching lines...) Expand all
40 void ExpectBucketCount(const std::string& name, 42 void ExpectBucketCount(const std::string& name,
41 base::HistogramBase::Sample sample, 43 base::HistogramBase::Sample sample,
42 base::HistogramBase::Count expected_count) const; 44 base::HistogramBase::Count expected_count) const;
43 45
44 // We don't know the values of the samples, but we know how many there are. 46 // We don't know the values of the samples, but we know how many there are.
45 // This measures the diff from the snapshot taken when this object was 47 // This measures the diff from the snapshot taken when this object was
46 // constructed. 48 // constructed.
47 void ExpectTotalCount(const std::string& name, 49 void ExpectTotalCount(const std::string& name,
48 base::HistogramBase::Count count) const; 50 base::HistogramBase::Count count) const;
49 51
52 // Returns a list of all of the buckets recorded since creation of this
53 // object, as pair<Sample, Count>, where the Sample is the min boundary of the
54 // bucket and the Count is the count recorded since creation.
ncarter (slow) 2015/06/24 17:28:44 This comment should have code showing the example
twifkak 2015/06/25 20:21:38 Done.
55 std::vector<std::pair<HistogramBase::Sample, HistogramBase::Count>>
56 GetAllSamples(const std::string& name);
57
50 // Access a modified HistogramSamples containing only what has been logged 58 // Access a modified HistogramSamples containing only what has been logged
51 // to the histogram since the creation of this object. 59 // to the histogram since the creation of this object.
52 scoped_ptr<HistogramSamples> GetHistogramSamplesSinceCreation( 60 scoped_ptr<HistogramSamples> GetHistogramSamplesSinceCreation(
53 const std::string& histogram_name); 61 const std::string& histogram_name);
54 62
55 private: 63 private:
56 // Verifies and asserts that value in the |sample| bucket matches the 64 // Verifies and asserts that value in the |sample| bucket matches the
57 // |expected_count|. The bucket's current value is determined from |samples| 65 // |expected_count|. The bucket's current value is determined from |samples|
58 // and is modified based on the snapshot stored for histogram |name|. 66 // and is modified based on the snapshot stored for histogram |name|.
59 void CheckBucketCount(const std::string& name, 67 void CheckBucketCount(const std::string& name,
(...skipping 12 matching lines...) Expand all
72 // lifecycle. This instance takes ownership of the samples, which are deleted 80 // lifecycle. This instance takes ownership of the samples, which are deleted
73 // when the instance is destroyed. 81 // when the instance is destroyed.
74 std::map<std::string, HistogramSamples*> histograms_snapshot_; 82 std::map<std::string, HistogramSamples*> histograms_snapshot_;
75 83
76 DISALLOW_COPY_AND_ASSIGN(HistogramTester); 84 DISALLOW_COPY_AND_ASSIGN(HistogramTester);
77 }; 85 };
78 86
79 } // namespace base 87 } // namespace base
80 88
81 #endif // BASE_TEST_HISTOGRAM_TESTER_H_ 89 #endif // BASE_TEST_HISTOGRAM_TESTER_H_
OLDNEW
« no previous file with comments | « no previous file | base/test/histogram_tester.cc » ('j') | base/test/histogram_tester_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698