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

Unified Diff: chrome/common/metrics/metrics_log_base.cc

Issue 10829466: SampleSet -> HistogramSamples (will be reused by SparseHistogram) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/common/metrics/metrics_log_base.h ('k') | chrome/common/metrics/metrics_service_base.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/metrics/metrics_log_base.cc
===================================================================
--- chrome/common/metrics/metrics_log_base.cc (revision 155400)
+++ chrome/common/metrics/metrics_log_base.cc (working copy)
@@ -7,6 +7,8 @@
#include "base/base64.h"
#include "base/basictypes.h"
#include "base/md5.h"
+#include "base/metrics/histogram_base.h"
+#include "base/metrics/histogram_samples.h"
#include "base/perftimer.h"
#include "base/string_number_conversions.h"
#include "base/sys_byteorder.h"
@@ -23,6 +25,9 @@
#define OPEN_ELEMENT_FOR_SCOPE(name) ScopedElement scoped_element(this, name)
using base::Histogram;
+using base::HistogramBase;
+using base::HistogramSamples;
+using base::SampleCountIterator;
using base::Time;
using base::TimeDelta;
using metrics::HistogramEventProto;
@@ -449,10 +454,9 @@
// the same infrastructure for logging StatsCounters, RatesCounters, etc.
void MetricsLogBase::RecordHistogramDelta(
const Histogram& histogram,
- const Histogram::SampleSet& snapshot) {
+ const HistogramSamples& snapshot) {
DCHECK(!locked_);
DCHECK_NE(0, snapshot.TotalCount());
- DCHECK_EQ(histogram.bucket_count(), snapshot.size());
// We will ignore the MAX_INT/infinite value in the last element of range[].
@@ -471,13 +475,17 @@
// TODO(jar): Remove sumsquares when protobuffer accepts this as optional.
WriteInt64Attribute("sumsquares", 0);
- for (size_t i = 0; i < histogram.bucket_count(); i++) {
- if (snapshot.counts(i)) {
- OPEN_ELEMENT_FOR_SCOPE("histogrambucket");
- WriteIntAttribute("min", histogram.ranges(i));
- WriteIntAttribute("max", histogram.ranges(i + 1));
- WriteIntAttribute("count", snapshot.counts(i));
- }
+ for (scoped_ptr<SampleCountIterator> it = snapshot.Iterator();
+ !it->Done();
+ it->Next()) {
+ OPEN_ELEMENT_FOR_SCOPE("histogrambucket");
+ HistogramBase::Sample min;
+ HistogramBase::Sample max;
+ HistogramBase::Count count;
+ it->Get(&min, &max, &count);
+ WriteIntAttribute("min", min);
+ WriteIntAttribute("max", max);
+ WriteIntAttribute("count", count);
}
// Write the protobuf version.
@@ -485,13 +493,20 @@
histogram_proto->set_name_hash(numeric_name_hash);
histogram_proto->set_sum(snapshot.sum());
- for (size_t i = 0; i < histogram.bucket_count(); ++i) {
- if (snapshot.counts(i)) {
- HistogramEventProto::Bucket* bucket = histogram_proto->add_bucket();
- bucket->set_min(histogram.ranges(i));
- bucket->set_max(histogram.ranges(i + 1));
- bucket->set_bucket_index(i);
- bucket->set_count(snapshot.counts(i));
- }
+ for (scoped_ptr<SampleCountIterator> it = snapshot.Iterator();
+ !it->Done();
+ it->Next()) {
+ HistogramBase::Sample min;
+ HistogramBase::Sample max;
+ HistogramBase::Count count;
+ it->Get(&min, &max, &count);
+ HistogramEventProto::Bucket* bucket = histogram_proto->add_bucket();
+ bucket->set_min(min);
+ bucket->set_max(max);
+ bucket->set_count(count);
+
+ size_t index;
+ if (it->GetBucketIndex(&index))
+ bucket->set_bucket_index(index);
}
}
« no previous file with comments | « chrome/common/metrics/metrics_log_base.h ('k') | chrome/common/metrics/metrics_service_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698