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

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

Issue 1852633002: Add UMA stats for time in paint+layout, compositing, paint invalidation and paint. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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.h
diff --git a/third_party/WebKit/Source/platform/Histogram.h b/third_party/WebKit/Source/platform/Histogram.h
index a88970454c9e2ff4dce33c2774f81081f6fcc363..542f321489be6d252cc4d67cda90b919020671b4 100644
--- a/third_party/WebKit/Source/platform/Histogram.h
+++ b/third_party/WebKit/Source/platform/Histogram.h
@@ -7,6 +7,7 @@
#include "base/metrics/histogram_base.h"
#include "platform/PlatformExport.h"
+#include "wtf/CurrentTime.h"
#include <stdint.h>
namespace base {
@@ -42,6 +43,33 @@ private:
base::HistogramBase* m_histogram;
};
+class PLATFORM_EXPORT ScopedUsHistogramTimer {
+public:
+ ScopedUsHistogramTimer(CustomCountHistogram& counter)
+ : m_startTime(WTF::monotonicallyIncreasingTime()),
pdr. 2016/04/01 00:03:16 Nit: indentation
chrishtr 2016/04/01 16:33:42 Done
+ m_counter(counter) {}
+
+ ~ScopedUsHistogramTimer()
+ {
+ m_counter.count(WTF::monotonicallyIncreasingTime() - m_startTime);
+ }
+
+private:
+ double m_startTime;
+ CustomCountHistogram& m_counter;
+};
+
+// Use code like this to record time, in microseconds, to execute a block of code:
+//
+// {
+// SCOPED_BLINK_UMA_HISTOGRAM_TIMER(myUmaStatName)
+// RunMyCode();
+// }
+// This macro records all times between 0us and 10 seconds.
wkorman 2016/04/01 00:15:30 In 95th pctile I believe we have seen for some met
chrishtr 2016/04/01 00:29:40 I've been cribbing off of the implementation of SC
Alexei Svitkine (slow) 2016/04/01 15:26:12 Yes, please change to 50 buckets. 100 bucket histo
chrishtr 2016/04/01 16:33:41 Done.
+#define SCOPED_BLINK_UMA_HISTOGRAM_TIMER(name) \
+DEFINE_STATIC_LOCAL(CustomCountHistogram, scopedUsCounter, (name, 0, 10000000, 100)); \
+ScopedUsHistogramTimer timer(scopedUsCounter);
+
} // namespace blink
#endif // Histogram_h

Powered by Google App Engine
This is Rietveld 408576698