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

Side by Side Diff: base/metrics/histogram.h

Issue 2867303004: [histogram] Make histograms more resistant to overflows. (Closed)
Patch Set: addressed comments from isherman@ 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 | « no previous file | base/metrics/histogram.cc » ('j') | base/metrics/histogram.cc » ('J')
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 // Histogram is an object that aggregates statistics, and can summarize them in 5 // Histogram is an object that aggregates statistics, and can summarize them in
6 // various forms, including ASCII graphical, HTML, and numerically (as a 6 // various forms, including ASCII graphical, HTML, and numerically (as a
7 // vector of numbers corresponding to each of the aggregating buckets). 7 // vector of numbers corresponding to each of the aggregating buckets).
8 8
9 // It supports calls to accumulate either time intervals (which are processed 9 // It supports calls to accumulate either time intervals (which are processed
10 // as integral number of milliseconds), or arbitrary integral units. 10 // as integral number of milliseconds), or arbitrary integral units.
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 friend class StatisticsRecorder; // To allow it to delete duplicates. 260 friend class StatisticsRecorder; // To allow it to delete duplicates.
261 friend class StatisticsRecorderTest; 261 friend class StatisticsRecorderTest;
262 262
263 friend BASE_EXPORT HistogramBase* DeserializeHistogramInfo( 263 friend BASE_EXPORT HistogramBase* DeserializeHistogramInfo(
264 base::PickleIterator* iter); 264 base::PickleIterator* iter);
265 static HistogramBase* DeserializeInfoImpl(base::PickleIterator* iter); 265 static HistogramBase* DeserializeInfoImpl(base::PickleIterator* iter);
266 266
267 // Implementation of SnapshotSamples function. 267 // Implementation of SnapshotSamples function.
268 std::unique_ptr<SampleVector> SnapshotSampleVector() const; 268 std::unique_ptr<SampleVector> SnapshotSampleVector() const;
269 269
270 // Create a copy of unlogged samples.
271 std::unique_ptr<SampleVector> SnapshotUnloggedSamples() const;
272
270 //---------------------------------------------------------------------------- 273 //----------------------------------------------------------------------------
271 // Helpers for emitting Ascii graphic. Each method appends data to output. 274 // Helpers for emitting Ascii graphic. Each method appends data to output.
272 275
273 void WriteAsciiImpl(bool graph_it, 276 void WriteAsciiImpl(bool graph_it,
274 const std::string& newline, 277 const std::string& newline,
275 std::string* output) const; 278 std::string* output) const;
276 279
277 // Find out how large (graphically) the largest bucket will appear to be. 280 // Find out how large (graphically) the largest bucket will appear to be.
278 double GetPeakBucketSize(const SampleVectorBase& samples) const; 281 double GetPeakBucketSize(const SampleVectorBase& samples) const;
279 282
(...skipping 16 matching lines...) Expand all
296 void GetCountAndBucketData(Count* count, 299 void GetCountAndBucketData(Count* count,
297 int64_t* sum, 300 int64_t* sum,
298 ListValue* buckets) const override; 301 ListValue* buckets) const override;
299 302
300 // Does not own this object. Should get from StatisticsRecorder. 303 // Does not own this object. Should get from StatisticsRecorder.
301 const BucketRanges* bucket_ranges_; 304 const BucketRanges* bucket_ranges_;
302 305
303 Sample declared_min_; // Less than this goes into the first bucket. 306 Sample declared_min_; // Less than this goes into the first bucket.
304 Sample declared_max_; // Over this goes into the last bucket. 307 Sample declared_max_; // Over this goes into the last bucket.
305 308
306 // Finally, provide the state that changes with the addition of each new 309 // Samples that have not yet been logged with SnapshotDelta().
307 // sample. 310 std::unique_ptr<HistogramSamples> unlogged_samples_;
308 std::unique_ptr<SampleVectorBase> samples_;
309 311
310 // Also keep a previous uploaded state for calculating deltas. 312 // Accumulation of all samples that have logged with SnapshotDelta().
311 std::unique_ptr<HistogramSamples> logged_samples_; 313 std::unique_ptr<HistogramSamples> logged_samples_;
312 314
313 // Flag to indicate if PrepareFinalDelta has been previously called. It is 315 // Flag to indicate if PrepareFinalDelta has been previously called. It is
314 // used to DCHECK that a final delta is not created multiple times. 316 // used to DCHECK that a final delta is not created multiple times.
315 mutable bool final_delta_created_ = false; 317 mutable bool final_delta_created_ = false;
316 318
317 DISALLOW_COPY_AND_ASSIGN(Histogram); 319 DISALLOW_COPY_AND_ASSIGN(Histogram);
318 }; 320 };
319 321
320 //------------------------------------------------------------------------------ 322 //------------------------------------------------------------------------------
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 static HistogramBase* DeserializeInfoImpl(base::PickleIterator* iter); 537 static HistogramBase* DeserializeInfoImpl(base::PickleIterator* iter);
536 538
537 static bool ValidateCustomRanges(const std::vector<Sample>& custom_ranges); 539 static bool ValidateCustomRanges(const std::vector<Sample>& custom_ranges);
538 540
539 DISALLOW_COPY_AND_ASSIGN(CustomHistogram); 541 DISALLOW_COPY_AND_ASSIGN(CustomHistogram);
540 }; 542 };
541 543
542 } // namespace base 544 } // namespace base
543 545
544 #endif // BASE_METRICS_HISTOGRAM_H_ 546 #endif // BASE_METRICS_HISTOGRAM_H_
OLDNEW
« no previous file with comments | « no previous file | base/metrics/histogram.cc » ('j') | base/metrics/histogram.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698