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

Side by Side 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, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef Histogram_h 5 #ifndef Histogram_h
6 #define Histogram_h 6 #define Histogram_h
7 7
8 #include "base/metrics/histogram_base.h" 8 #include "base/metrics/histogram_base.h"
9 #include "platform/PlatformExport.h" 9 #include "platform/PlatformExport.h"
10 #include "wtf/CurrentTime.h"
10 #include <stdint.h> 11 #include <stdint.h>
11 12
12 namespace base { 13 namespace base {
13 class HistogramBase; 14 class HistogramBase;
14 }; 15 };
15 16
16 namespace blink { 17 namespace blink {
17 18
18 class PLATFORM_EXPORT CustomCountHistogram { 19 class PLATFORM_EXPORT CustomCountHistogram {
19 public: 20 public:
(...skipping 15 matching lines...) Expand all
35 class PLATFORM_EXPORT SparseHistogram { 36 class PLATFORM_EXPORT SparseHistogram {
36 public: 37 public:
37 explicit SparseHistogram(const char* name); 38 explicit SparseHistogram(const char* name);
38 39
39 void sample(base::HistogramBase::Sample); 40 void sample(base::HistogramBase::Sample);
40 41
41 private: 42 private:
42 base::HistogramBase* m_histogram; 43 base::HistogramBase* m_histogram;
43 }; 44 };
44 45
46 class PLATFORM_EXPORT ScopedUsHistogramTimer {
47 public:
48 ScopedUsHistogramTimer(CustomCountHistogram& counter)
49 : m_startTime(WTF::monotonicallyIncreasingTime()),
pdr. 2016/04/01 00:03:16 Nit: indentation
chrishtr 2016/04/01 16:33:42 Done
50 m_counter(counter) {}
51
52 ~ScopedUsHistogramTimer()
53 {
54 m_counter.count(WTF::monotonicallyIncreasingTime() - m_startTime);
55 }
56
57 private:
58 double m_startTime;
59 CustomCountHistogram& m_counter;
60 };
61
62 // Use code like this to record time, in microseconds, to execute a block of cod e:
63 //
64 // {
65 // SCOPED_BLINK_UMA_HISTOGRAM_TIMER(myUmaStatName)
66 // RunMyCode();
67 // }
68 // 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.
69 #define SCOPED_BLINK_UMA_HISTOGRAM_TIMER(name) \
70 DEFINE_STATIC_LOCAL(CustomCountHistogram, scopedUsCounter, (name, 0, 10000000, 1 00)); \
71 ScopedUsHistogramTimer timer(scopedUsCounter);
72
45 } // namespace blink 73 } // namespace blink
46 74
47 #endif // Histogram_h 75 #endif // Histogram_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698