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

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

Issue 2811713003: Embed a single sample in histogram metadata. (Closed)
Patch Set: rebased Created 3 years, 7 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/persistent_histogram_allocator.cc ('k') | base/metrics/sample_map.cc » ('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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/persistent_sample_map.h" 5 #include "base/metrics/persistent_sample_map.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "base/metrics/histogram_macros.h" 9 #include "base/metrics/histogram_macros.h"
10 #include "base/metrics/persistent_histogram_allocator.h" 10 #include "base/metrics/persistent_histogram_allocator.h"
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 Metadata* meta) 111 Metadata* meta)
112 : HistogramSamples(id, meta), allocator_(allocator) {} 112 : HistogramSamples(id, meta), allocator_(allocator) {}
113 113
114 PersistentSampleMap::~PersistentSampleMap() { 114 PersistentSampleMap::~PersistentSampleMap() {
115 if (records_) 115 if (records_)
116 records_->Release(this); 116 records_->Release(this);
117 } 117 }
118 118
119 void PersistentSampleMap::Accumulate(Sample value, Count count) { 119 void PersistentSampleMap::Accumulate(Sample value, Count count) {
120 *GetOrCreateSampleCountStorage(value) += count; 120 *GetOrCreateSampleCountStorage(value) += count;
121 IncreaseSum(static_cast<int64_t>(count) * value); 121 IncreaseSumAndCount(static_cast<int64_t>(count) * value, count);
122 IncreaseRedundantCount(count);
123 } 122 }
124 123
125 Count PersistentSampleMap::GetCount(Sample value) const { 124 Count PersistentSampleMap::GetCount(Sample value) const {
126 // Have to override "const" to make sure all samples have been loaded before 125 // Have to override "const" to make sure all samples have been loaded before
127 // being able to know what value to return. 126 // being able to know what value to return.
128 Count* count_pointer = 127 Count* count_pointer =
129 const_cast<PersistentSampleMap*>(this)->GetSampleCountStorage(value); 128 const_cast<PersistentSampleMap*>(this)->GetSampleCountStorage(value);
130 return count_pointer ? *count_pointer : 0; 129 return count_pointer ? *count_pointer : 0;
131 } 130 }
132 131
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 found_count = &record->count; 327 found_count = &record->count;
329 if (!import_everything) 328 if (!import_everything)
330 break; 329 break;
331 } 330 }
332 } 331 }
333 332
334 return found_count; 333 return found_count;
335 } 334 }
336 335
337 } // namespace base 336 } // namespace base
OLDNEW
« no previous file with comments | « base/metrics/persistent_histogram_allocator.cc ('k') | base/metrics/sample_map.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698