| 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
|
|
|