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

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
« no previous file with comments | « third_party/WebKit/Source/platform/DEPS ('k') | third_party/WebKit/Source/platform/HistogramTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..73ed72185b985cab747914eea7d74b47ed6c419c 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 {
@@ -23,7 +24,6 @@ public:
protected:
explicit CustomCountHistogram(base::HistogramBase*);
-private:
base::HistogramBase* m_histogram;
};
@@ -42,6 +42,37 @@ private:
base::HistogramBase* m_histogram;
};
+
+
+class PLATFORM_EXPORT ScopedUsHistogramTimer {
+public:
+ ScopedUsHistogramTimer(CustomCountHistogram& counter)
+ : m_startTime(WTF::monotonicallyIncreasingTime()),
+ m_counter(counter) {}
+
+ ~ScopedUsHistogramTimer()
+ {
+ m_counter.count((WTF::monotonicallyIncreasingTime() - m_startTime) * base::Time::kMicrosecondsPerSecond);
+ }
+
+private:
+ // In seconds.
+ 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.
+// Do not change this macro without renaming all metrics that use it!
+#define SCOPED_BLINK_UMA_HISTOGRAM_TIMER(name) \
+DEFINE_STATIC_LOCAL(CustomCountHistogram, scopedUsCounter, (name, 0, 10000000, 50)); \
+ScopedUsHistogramTimer timer(scopedUsCounter);
+
} // namespace blink
#endif // Histogram_h
« no previous file with comments | « third_party/WebKit/Source/platform/DEPS ('k') | third_party/WebKit/Source/platform/HistogramTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698