OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "base/test/histogram_recorder.h" | |
6 | |
7 #include "base/metrics/histogram.h" | |
8 #include "base/metrics/statistics_recorder.h" | |
9 #include "base/stl_util.h" | |
10 | |
11 namespace base { | |
12 | |
13 HistogramRecorder::HistogramRecorder() { | |
14 // Record any histogram data that exists when the object is created so it can | |
15 // be subtracted later. | |
16 StatisticsRecorder::Initialize(); | |
17 StatisticsRecorder::Histograms histograms; | |
18 StatisticsRecorder::GetSnapshot("", &histograms); | |
19 for (size_t i = 0; i < histograms.size(); i++) { | |
20 original_samples_[histograms[i]->histogram_name()] = | |
21 histograms[i]->SnapshotSamples().release(); | |
22 } | |
23 } | |
24 | |
25 HistogramRecorder::~HistogramRecorder() { | |
26 STLDeleteValues(&original_samples_); | |
27 } | |
28 | |
29 scoped_ptr<HistogramSamples> | |
30 HistogramRecorder::GetHistogramSamplesSinceCreation( | |
31 const std::string& histogram_name) { | |
32 HistogramBase* histogram = StatisticsRecorder::FindHistogram(histogram_name); | |
33 if (!histogram) | |
34 return scoped_ptr<HistogramSamples>(); | |
35 scoped_ptr<HistogramSamples> named_samples(histogram->SnapshotSamples()); | |
36 HistogramSamples* named_original_samples = original_samples_[histogram_name]; | |
37 if (named_original_samples) | |
38 named_samples->Subtract(*named_original_samples); | |
blundell
2013/07/12 13:22:42
I believe that as of pretty recently, you are supp
lpromero
2013/07/17 13:40:48
Done.
Ryan Sleevi
2013/07/17 17:03:26
Can you please point where?
scoped_ptr<> is inten
lpromero
2013/07/18 07:43:37
Done.
blundell
2013/07/18 07:43:54
Oops, I had misunderstood what was going on in crb
| |
39 return named_samples.Pass(); | |
40 } | |
41 | |
42 } // namespace base | |
OLD | NEW |