OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Intel Inc. All rights reserved. | 2 * Copyright (C) 2012 Intel Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 12 matching lines...) Expand all Loading... |
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
24 */ | 24 */ |
25 | 25 |
26 #include "core/timing/PerformanceUserTiming.h" | 26 #include "core/timing/PerformanceUserTiming.h" |
27 | 27 |
28 #include "bindings/core/v8/ExceptionState.h" | 28 #include "bindings/core/v8/ExceptionState.h" |
29 #include "core/dom/ExceptionCode.h" | 29 #include "core/dom/ExceptionCode.h" |
30 #include "core/timing/PerformanceBase.h" | 30 #include "core/timing/PerformanceBase.h" |
31 #include "core/timing/PerformanceMark.h" | 31 #include "core/timing/PerformanceMark.h" |
32 #include "core/timing/PerformanceMeasure.h" | 32 #include "core/timing/PerformanceMeasure.h" |
| 33 #include "platform/Histogram.h" |
33 #include "platform/TraceEvent.h" | 34 #include "platform/TraceEvent.h" |
34 #include "public/platform/Platform.h" | 35 #include "public/platform/Platform.h" |
35 #include "wtf/text/StringHash.h" | 36 #include "wtf/text/StringHash.h" |
36 | 37 |
37 namespace blink { | 38 namespace blink { |
38 | 39 |
39 namespace { | 40 namespace { |
40 | 41 |
41 using RestrictedKeyMap = HashMap<String, NavigationTimingFunction>; | 42 using RestrictedKeyMap = HashMap<String, NavigationTimingFunction>; |
42 | 43 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 { | 108 { |
108 if (restrictedKeyMap().contains(markName)) { | 109 if (restrictedKeyMap().contains(markName)) { |
109 exceptionState.throwDOMException(SyntaxError, "'" + markName + "' is par
t of the PerformanceTiming interface, and cannot be used as a mark name."); | 110 exceptionState.throwDOMException(SyntaxError, "'" + markName + "' is par
t of the PerformanceTiming interface, and cannot be used as a mark name."); |
110 return nullptr; | 111 return nullptr; |
111 } | 112 } |
112 | 113 |
113 TRACE_EVENT_COPY_MARK("blink.user_timing", markName.utf8().data()); | 114 TRACE_EVENT_COPY_MARK("blink.user_timing", markName.utf8().data()); |
114 double startTime = m_performance->now(); | 115 double startTime = m_performance->now(); |
115 PerformanceEntry* entry = PerformanceMark::create(markName, startTime); | 116 PerformanceEntry* entry = PerformanceMark::create(markName, startTime); |
116 insertPerformanceEntry(m_marksMap, *entry); | 117 insertPerformanceEntry(m_marksMap, *entry); |
117 Platform::current()->histogramCustomCounts("PLT.UserTiming_Mark", static_cas
t<int>(startTime), 0, 600000, 100); | 118 DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, userTimingMarkHistogra
m, new CustomCountHistogram("PLT.UserTiming_Mark", 0, 600000, 100)); |
| 119 userTimingMarkHistogram.count(static_cast<int>(startTime)); |
118 return entry; | 120 return entry; |
119 } | 121 } |
120 | 122 |
121 void UserTiming::clearMarks(const String& markName) | 123 void UserTiming::clearMarks(const String& markName) |
122 { | 124 { |
123 clearPeformanceEntries(m_marksMap, markName); | 125 clearPeformanceEntries(m_marksMap, markName); |
124 } | 126 } |
125 | 127 |
126 double UserTiming::findExistingMarkStartTime(const String& markName, ExceptionSt
ate& exceptionState) | 128 double UserTiming::findExistingMarkStartTime(const String& markName, ExceptionSt
ate& exceptionState) |
127 { | 129 { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 // navigation, whereas trace events accept double seconds based off of | 168 // navigation, whereas trace events accept double seconds based off of |
167 // CurrentTime::monotonicallyIncreasingTime(). | 169 // CurrentTime::monotonicallyIncreasingTime(). |
168 double startTimeMonotonic = m_performance->timeOrigin() + startTime / 1000.0
; | 170 double startTimeMonotonic = m_performance->timeOrigin() + startTime / 1000.0
; |
169 double endTimeMonotonic = m_performance->timeOrigin() + endTime / 1000.0; | 171 double endTimeMonotonic = m_performance->timeOrigin() + endTime / 1000.0; |
170 | 172 |
171 TRACE_EVENT_COPY_NESTABLE_ASYNC_BEGIN_WITH_TIMESTAMP0("blink.user_timing", m
easureName.utf8().data(), WTF::StringHash::hash(measureName), startTimeMonotonic
); | 173 TRACE_EVENT_COPY_NESTABLE_ASYNC_BEGIN_WITH_TIMESTAMP0("blink.user_timing", m
easureName.utf8().data(), WTF::StringHash::hash(measureName), startTimeMonotonic
); |
172 TRACE_EVENT_COPY_NESTABLE_ASYNC_END_WITH_TIMESTAMP0("blink.user_timing", mea
sureName.utf8().data(), WTF::StringHash::hash(measureName), endTimeMonotonic); | 174 TRACE_EVENT_COPY_NESTABLE_ASYNC_END_WITH_TIMESTAMP0("blink.user_timing", mea
sureName.utf8().data(), WTF::StringHash::hash(measureName), endTimeMonotonic); |
173 | 175 |
174 PerformanceEntry* entry = PerformanceMeasure::create(measureName, startTime,
endTime); | 176 PerformanceEntry* entry = PerformanceMeasure::create(measureName, startTime,
endTime); |
175 insertPerformanceEntry(m_measuresMap, *entry); | 177 insertPerformanceEntry(m_measuresMap, *entry); |
176 if (endTime >= startTime) | 178 if (endTime >= startTime) { |
177 Platform::current()->histogramCustomCounts("PLT.UserTiming_MeasureDurati
on", static_cast<int>(endTime - startTime), 0, 600000, 100); | 179 DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, measureDurationHis
togram, new CustomCountHistogram("PLT.UserTiming_MeasureDuration", 0, 600000, 10
0)); |
| 180 measureDurationHistogram.count(static_cast<int>(endTime - startTime)); |
| 181 } |
178 return entry; | 182 return entry; |
179 } | 183 } |
180 | 184 |
181 void UserTiming::clearMeasures(const String& measureName) | 185 void UserTiming::clearMeasures(const String& measureName) |
182 { | 186 { |
183 clearPeformanceEntries(m_measuresMap, measureName); | 187 clearPeformanceEntries(m_measuresMap, measureName); |
184 } | 188 } |
185 | 189 |
186 static PerformanceEntryVector convertToEntrySequence(const PerformanceEntryMap&
performanceEntryMap) | 190 static PerformanceEntryVector convertToEntrySequence(const PerformanceEntryMap&
performanceEntryMap) |
187 { | 191 { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 } | 229 } |
226 | 230 |
227 DEFINE_TRACE(UserTiming) | 231 DEFINE_TRACE(UserTiming) |
228 { | 232 { |
229 visitor->trace(m_performance); | 233 visitor->trace(m_performance); |
230 visitor->trace(m_marksMap); | 234 visitor->trace(m_marksMap); |
231 visitor->trace(m_measuresMap); | 235 visitor->trace(m_measuresMap); |
232 } | 236 } |
233 | 237 |
234 } // namespace blink | 238 } // namespace blink |
OLD | NEW |