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

Unified Diff: third_party/WebKit/Source/platform/Histogram.cpp

Issue 1647883004: Support caching histograms so that a lookup isn't done in each iteration. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add explicit to protected ctor as well Created 4 years, 11 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
Index: third_party/WebKit/Source/platform/Histogram.cpp
diff --git a/third_party/WebKit/Source/platform/Histogram.cpp b/third_party/WebKit/Source/platform/Histogram.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..0ff8e9ebc52ccd4a702698dfe9c43b06542b7a3f
--- /dev/null
+++ b/third_party/WebKit/Source/platform/Histogram.cpp
@@ -0,0 +1,42 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "platform/Histogram.h"
+
+#include "base/metrics/histogram.h"
+#include "base/metrics/sparse_histogram.h"
+
+namespace blink {
+
+CustomCountHistogram::CustomCountHistogram(const char* name, int32_t min, int32_t max, int32_t bucketCount)
+{
+ m_histogram = base::Histogram::FactoryGet(name, min, max, bucketCount, base::HistogramBase::kNoFlags);
Alexei Svitkine (slow) 2016/02/01 19:55:31 I think you want kUmaTargetedHistogramFlag here an
+}
+
+CustomCountHistogram::CustomCountHistogram(base::HistogramBase* histogram)
+ : m_histogram(histogram)
+{
+}
+
+void CustomCountHistogram::count(int32_t sample)
+{
+ m_histogram->Add(sample);
+}
+
+EnumerationHistogram::EnumerationHistogram(const char* name, int32_t boundaryValue)
+ : CustomCountHistogram(base::LinearHistogram::FactoryGet(name, 1, boundaryValue, boundaryValue + 1, base::HistogramBase::kNoFlags))
+{
+}
+
+SparseHistogram::SparseHistogram(const char* name)
+{
+ m_histogram = base::SparseHistogram::FactoryGet(name, base::HistogramBase::kUmaTargetedHistogramFlag);
+}
+
+void SparseHistogram::sample(int32_t sample)
+{
+ m_histogram->Add(sample);
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698