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

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

Issue 1485763002: Merge multiple histogram snapshots into single one for reporting. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@shared-histograms
Patch Set: addressed remaining review comments by Alexei Created 4 years, 10 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') | no next file » | 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 "base/metrics/sparse_histogram.h" 5 #include "base/metrics/sparse_histogram.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/metrics/metrics_hashes.h" 9 #include "base/metrics/metrics_hashes.h"
10 #include "base/metrics/sample_map.h" 10 #include "base/metrics/sample_map.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 } 70 }
71 71
72 scoped_ptr<HistogramSamples> SparseHistogram::SnapshotSamples() const { 72 scoped_ptr<HistogramSamples> SparseHistogram::SnapshotSamples() const {
73 scoped_ptr<SampleMap> snapshot(new SampleMap(name_hash())); 73 scoped_ptr<SampleMap> snapshot(new SampleMap(name_hash()));
74 74
75 base::AutoLock auto_lock(lock_); 75 base::AutoLock auto_lock(lock_);
76 snapshot->Add(samples_); 76 snapshot->Add(samples_);
77 return std::move(snapshot); 77 return std::move(snapshot);
78 } 78 }
79 79
80 scoped_ptr<HistogramSamples> SparseHistogram::SnapshotDelta() {
81 scoped_ptr<SampleMap> snapshot(new SampleMap(name_hash()));
82 base::AutoLock auto_lock(lock_);
83 snapshot->Add(samples_);
84
85 // Subtract what was previously logged and update that information.
86 snapshot->Subtract(logged_samples_);
87 logged_samples_.Add(*snapshot);
88 return std::move(snapshot);
89 }
90
80 void SparseHistogram::AddSamples(const HistogramSamples& samples) { 91 void SparseHistogram::AddSamples(const HistogramSamples& samples) {
81 base::AutoLock auto_lock(lock_); 92 base::AutoLock auto_lock(lock_);
82 samples_.Add(samples); 93 samples_.Add(samples);
83 } 94 }
84 95
85 bool SparseHistogram::AddSamplesFromPickle(PickleIterator* iter) { 96 bool SparseHistogram::AddSamplesFromPickle(PickleIterator* iter) {
86 base::AutoLock auto_lock(lock_); 97 base::AutoLock auto_lock(lock_);
87 return samples_.AddFromPickle(iter); 98 return samples_.AddFromPickle(iter);
88 } 99 }
89 100
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 std::string* output) const { 197 std::string* output) const {
187 StringAppendF(output, 198 StringAppendF(output,
188 "Histogram: %s recorded %d samples", 199 "Histogram: %s recorded %d samples",
189 histogram_name().c_str(), 200 histogram_name().c_str(),
190 total_count); 201 total_count);
191 if (flags() & ~kHexRangePrintingFlag) 202 if (flags() & ~kHexRangePrintingFlag)
192 StringAppendF(output, " (flags = 0x%x)", flags() & ~kHexRangePrintingFlag); 203 StringAppendF(output, " (flags = 0x%x)", flags() & ~kHexRangePrintingFlag);
193 } 204 }
194 205
195 } // namespace base 206 } // namespace base
OLDNEW
« no previous file with comments | « base/metrics/sparse_histogram.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698