OLD | NEW |
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 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 logged_samples_.swap(snapshot); | 446 logged_samples_.swap(snapshot); |
447 return SnapshotSampleVector(); | 447 return SnapshotSampleVector(); |
448 } | 448 } |
449 | 449 |
450 // Subtract what was previously logged and update that information. | 450 // Subtract what was previously logged and update that information. |
451 snapshot->Subtract(*logged_samples_); | 451 snapshot->Subtract(*logged_samples_); |
452 logged_samples_->Add(*snapshot); | 452 logged_samples_->Add(*snapshot); |
453 return snapshot; | 453 return snapshot; |
454 } | 454 } |
455 | 455 |
| 456 std::unique_ptr<HistogramSamples> Histogram::SnapshotDifference() const { |
| 457 std::unique_ptr<HistogramSamples> snapshot = SnapshotSampleVector(); |
| 458 |
| 459 // Subtract what was previously logged and then return. |
| 460 if (logged_samples_) |
| 461 snapshot->Subtract(*logged_samples_); |
| 462 return snapshot; |
| 463 } |
| 464 |
456 void Histogram::AddSamples(const HistogramSamples& samples) { | 465 void Histogram::AddSamples(const HistogramSamples& samples) { |
457 samples_->Add(samples); | 466 samples_->Add(samples); |
458 } | 467 } |
459 | 468 |
460 bool Histogram::AddSamplesFromPickle(PickleIterator* iter) { | 469 bool Histogram::AddSamplesFromPickle(PickleIterator* iter) { |
461 return samples_->AddFromPickle(iter); | 470 return samples_->AddFromPickle(iter); |
462 } | 471 } |
463 | 472 |
464 // The following methods provide a graphical histogram display. | 473 // The following methods provide a graphical histogram display. |
465 void Histogram::WriteHTMLGraph(std::string* output) const { | 474 void Histogram::WriteHTMLGraph(std::string* output) const { |
(...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1165 Sample sample = custom_ranges[i]; | 1174 Sample sample = custom_ranges[i]; |
1166 if (sample < 0 || sample > HistogramBase::kSampleType_MAX - 1) | 1175 if (sample < 0 || sample > HistogramBase::kSampleType_MAX - 1) |
1167 return false; | 1176 return false; |
1168 if (sample != 0) | 1177 if (sample != 0) |
1169 has_valid_range = true; | 1178 has_valid_range = true; |
1170 } | 1179 } |
1171 return has_valid_range; | 1180 return has_valid_range; |
1172 } | 1181 } |
1173 | 1182 |
1174 } // namespace base | 1183 } // namespace base |
OLD | NEW |