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

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

Issue 1891913002: Support saving browser metrics to disk and reading them during next run. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: removed some unnecessary includes Created 4 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/histogram.h ('k') | base/metrics/histogram_base.h » ('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 (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 // See header file for details and examples. 8 // See header file for details and examples.
9 9
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 samples_->Accumulate(value, count); 432 samples_->Accumulate(value, count);
433 433
434 FindAndRunCallback(value); 434 FindAndRunCallback(value);
435 } 435 }
436 436
437 std::unique_ptr<HistogramSamples> Histogram::SnapshotSamples() const { 437 std::unique_ptr<HistogramSamples> Histogram::SnapshotSamples() const {
438 return SnapshotSampleVector(); 438 return SnapshotSampleVector();
439 } 439 }
440 440
441 std::unique_ptr<HistogramSamples> Histogram::SnapshotDelta() { 441 std::unique_ptr<HistogramSamples> Histogram::SnapshotDelta() {
442 DCHECK(!final_delta_created_);
443
442 std::unique_ptr<HistogramSamples> snapshot = SnapshotSampleVector(); 444 std::unique_ptr<HistogramSamples> snapshot = SnapshotSampleVector();
443 if (!logged_samples_) { 445 if (!logged_samples_) {
444 // If nothing has been previously logged, save this one as 446 // If nothing has been previously logged, save this one as
445 // |logged_samples_| and gather another snapshot to return. 447 // |logged_samples_| and gather another snapshot to return.
446 logged_samples_.swap(snapshot); 448 logged_samples_.swap(snapshot);
447 return SnapshotSampleVector(); 449 return SnapshotSampleVector();
448 } 450 }
449 451
450 // Subtract what was previously logged and update that information. 452 // Subtract what was previously logged and update that information.
451 snapshot->Subtract(*logged_samples_); 453 snapshot->Subtract(*logged_samples_);
452 logged_samples_->Add(*snapshot); 454 logged_samples_->Add(*snapshot);
453 return snapshot; 455 return snapshot;
454 } 456 }
455 457
458 std::unique_ptr<HistogramSamples> Histogram::SnapshotFinalDelta() const {
459 DCHECK(!final_delta_created_);
460 final_delta_created_ = true;
461
462 std::unique_ptr<HistogramSamples> snapshot = SnapshotSampleVector();
463
464 // Subtract what was previously logged and then return.
465 if (logged_samples_)
466 snapshot->Subtract(*logged_samples_);
467 return snapshot;
468 }
469
456 void Histogram::AddSamples(const HistogramSamples& samples) { 470 void Histogram::AddSamples(const HistogramSamples& samples) {
457 samples_->Add(samples); 471 samples_->Add(samples);
458 } 472 }
459 473
460 bool Histogram::AddSamplesFromPickle(PickleIterator* iter) { 474 bool Histogram::AddSamplesFromPickle(PickleIterator* iter) {
461 return samples_->AddFromPickle(iter); 475 return samples_->AddFromPickle(iter);
462 } 476 }
463 477
464 // The following methods provide a graphical histogram display. 478 // The following methods provide a graphical histogram display.
465 void Histogram::WriteHTMLGraph(std::string* output) const { 479 void Histogram::WriteHTMLGraph(std::string* output) const {
(...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after
1165 Sample sample = custom_ranges[i]; 1179 Sample sample = custom_ranges[i];
1166 if (sample < 0 || sample > HistogramBase::kSampleType_MAX - 1) 1180 if (sample < 0 || sample > HistogramBase::kSampleType_MAX - 1)
1167 return false; 1181 return false;
1168 if (sample != 0) 1182 if (sample != 0)
1169 has_valid_range = true; 1183 has_valid_range = true;
1170 } 1184 }
1171 return has_valid_range; 1185 return has_valid_range;
1172 } 1186 }
1173 1187
1174 } // namespace base 1188 } // namespace base
OLDNEW
« no previous file with comments | « base/metrics/histogram.h ('k') | base/metrics/histogram_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698