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

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

Issue 1256363002: Add support to increase a UMA histogram bucket by an aribitrary integer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Change variable name and fix a typo Created 5 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
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 "base/metrics/sample_map.h" 7 #include "base/metrics/sample_map.h"
8 #include "base/metrics/statistics_recorder.h" 8 #include "base/metrics/statistics_recorder.h"
9 #include "base/pickle.h" 9 #include "base/pickle.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 47
48 void SparseHistogram::Add(Sample value) { 48 void SparseHistogram::Add(Sample value) {
49 { 49 {
50 base::AutoLock auto_lock(lock_); 50 base::AutoLock auto_lock(lock_);
51 samples_.Accumulate(value, 1); 51 samples_.Accumulate(value, 1);
52 } 52 }
53 53
54 FindAndRunCallback(value); 54 FindAndRunCallback(value);
55 } 55 }
56 56
57 void SparseHistogram::MultiAdd(Sample value, int repetition) {
58 {
59 base::AutoLock auto_lock(lock_);
60 samples_.Accumulate(value, repetition);
61 }
62
63 FindAndRunCallback(value);
64 }
65
57 scoped_ptr<HistogramSamples> SparseHistogram::SnapshotSamples() const { 66 scoped_ptr<HistogramSamples> SparseHistogram::SnapshotSamples() const {
58 scoped_ptr<SampleMap> snapshot(new SampleMap()); 67 scoped_ptr<SampleMap> snapshot(new SampleMap());
59 68
60 base::AutoLock auto_lock(lock_); 69 base::AutoLock auto_lock(lock_);
61 snapshot->Add(samples_); 70 snapshot->Add(samples_);
62 return snapshot.Pass(); 71 return snapshot.Pass();
63 } 72 }
64 73
65 void SparseHistogram::AddSamples(const HistogramSamples& samples) { 74 void SparseHistogram::AddSamples(const HistogramSamples& samples) {
66 base::AutoLock auto_lock(lock_); 75 base::AutoLock auto_lock(lock_);
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 std::string* output) const { 179 std::string* output) const {
171 StringAppendF(output, 180 StringAppendF(output,
172 "Histogram: %s recorded %d samples", 181 "Histogram: %s recorded %d samples",
173 histogram_name().c_str(), 182 histogram_name().c_str(),
174 total_count); 183 total_count);
175 if (flags() & ~kHexRangePrintingFlag) 184 if (flags() & ~kHexRangePrintingFlag)
176 StringAppendF(output, " (flags = 0x%x)", flags() & ~kHexRangePrintingFlag); 185 StringAppendF(output, " (flags = 0x%x)", flags() & ~kHexRangePrintingFlag);
177 } 186 }
178 187
179 } // namespace base 188 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698