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

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

Issue 1840843004: Improve efficiency of persistent sparse histograms. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@improved-pma-iterator
Patch Set: added comment clarifying loop behavior Created 4 years, 8 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/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/metrics/metrics_hashes.h" 10 #include "base/metrics/metrics_hashes.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 } else { 67 } else {
68 ReportHistogramActivity(*histogram, HISTOGRAM_LOOKUP); 68 ReportHistogramActivity(*histogram, HISTOGRAM_LOOKUP);
69 } 69 }
70 70
71 DCHECK_EQ(SPARSE_HISTOGRAM, histogram->GetHistogramType()); 71 DCHECK_EQ(SPARSE_HISTOGRAM, histogram->GetHistogramType());
72 return histogram; 72 return histogram;
73 } 73 }
74 74
75 // static 75 // static
76 std::unique_ptr<HistogramBase> SparseHistogram::PersistentCreate( 76 std::unique_ptr<HistogramBase> SparseHistogram::PersistentCreate(
77 PersistentMemoryAllocator* allocator, 77 PersistentHistogramAllocator* allocator,
78 const std::string& name, 78 const std::string& name,
79 HistogramSamples::Metadata* meta, 79 HistogramSamples::Metadata* meta,
80 HistogramSamples::Metadata* logged_meta) { 80 HistogramSamples::Metadata* logged_meta) {
81 return WrapUnique( 81 return WrapUnique(
82 new SparseHistogram(allocator, name, meta, logged_meta)); 82 new SparseHistogram(allocator, name, meta, logged_meta));
83 } 83 }
84 84
85 SparseHistogram::~SparseHistogram() {} 85 SparseHistogram::~SparseHistogram() {}
86 86
87 uint64_t SparseHistogram::name_hash() const { 87 uint64_t SparseHistogram::name_hash() const {
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 158
159 bool SparseHistogram::SerializeInfoImpl(Pickle* pickle) const { 159 bool SparseHistogram::SerializeInfoImpl(Pickle* pickle) const {
160 return pickle->WriteString(histogram_name()) && pickle->WriteInt(flags()); 160 return pickle->WriteString(histogram_name()) && pickle->WriteInt(flags());
161 } 161 }
162 162
163 SparseHistogram::SparseHistogram(const std::string& name) 163 SparseHistogram::SparseHistogram(const std::string& name)
164 : HistogramBase(name), 164 : HistogramBase(name),
165 samples_(new SampleMap(HashMetricName(name))), 165 samples_(new SampleMap(HashMetricName(name))),
166 logged_samples_(new SampleMap(samples_->id())) {} 166 logged_samples_(new SampleMap(samples_->id())) {}
167 167
168 SparseHistogram::SparseHistogram(PersistentMemoryAllocator* allocator, 168 SparseHistogram::SparseHistogram(PersistentHistogramAllocator* allocator,
169 const std::string& name, 169 const std::string& name,
170 HistogramSamples::Metadata* meta, 170 HistogramSamples::Metadata* meta,
171 HistogramSamples::Metadata* logged_meta) 171 HistogramSamples::Metadata* logged_meta)
172 : HistogramBase(name), 172 : HistogramBase(name),
173 // While other histogram types maintain a static vector of values with 173 // While other histogram types maintain a static vector of values with
174 // sufficient space for both "active" and "logged" samples, with each 174 // sufficient space for both "active" and "logged" samples, with each
175 // SampleVector being given the appropriate half, sparse histograms 175 // SampleVector being given the appropriate half, sparse histograms
176 // have no such initial allocation. Each sample has its own record 176 // have no such initial allocation. Each sample has its own record
177 // attached to a single PersistentSampleMap by a common 64-bit identifier. 177 // attached to a single PersistentSampleMap by a common 64-bit identifier.
178 // Since a sparse histogram has two sample maps (active and logged), 178 // Since a sparse histogram has two sample maps (active and logged),
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 std::string* output) const { 266 std::string* output) const {
267 StringAppendF(output, 267 StringAppendF(output,
268 "Histogram: %s recorded %d samples", 268 "Histogram: %s recorded %d samples",
269 histogram_name().c_str(), 269 histogram_name().c_str(),
270 total_count); 270 total_count);
271 if (flags() & ~kHexRangePrintingFlag) 271 if (flags() & ~kHexRangePrintingFlag)
272 StringAppendF(output, " (flags = 0x%x)", flags() & ~kHexRangePrintingFlag); 272 StringAppendF(output, " (flags = 0x%x)", flags() & ~kHexRangePrintingFlag);
273 } 273 }
274 274
275 } // namespace base 275 } // 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