Changeset 188946 in webkit
- Timestamp:
- Aug 25, 2015 11:29:48 PM (9 years ago)
- Location:
- trunk/Source/WebInspectorUI
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebInspectorUI/ChangeLog
r188916 r188946 1 2015-08-25 Brian Burg <bburg@apple.com> 2 3 Web Inspector: message dispatch metrics should use high-resolution timing data 4 https://bugs.webkit.org/show_bug.cgi?id=135467 5 6 Reviewed by Timothy Hatcher. 7 8 Use performance.now if it's available, otherwise fallback to Date.now(). 9 Format timestamps with fixed decimal point, and sprinkle some ES6. 10 11 * UserInterface/Base/Utilities.js: 12 (timestamp): Added. 13 * UserInterface/Protocol/InspectorBackend.js: 14 (InspectorBackendClass): 15 (InspectorBackendClass.prototype._sendCommandToBackendWithCallback): 16 (InspectorBackendClass.prototype._dispatchEvent): 17 * UserInterface/Protocol/MessageDispatcher.js: 18 (WebInspector.dispatchNextQueuedMessageFromBackend): 19 (WebInspector.dispatchMessageFromBackend): Be consistent about using `this`. 20 1 21 2015-08-25 Matt Baker <mattbaker@apple.com> 2 22 -
trunk/Source/WebInspectorUI/UserInterface/Base/Utilities.js
r188750 r188946 1125 1125 return new Blob(byteArrays, {type: mimeType}); 1126 1126 } 1127 1128 // FIXME: This can be removed when WEB_TIMING is enabled for all platforms. 1129 function timestamp() 1130 { 1131 return window.performance ? performance.now() : Date.now(); 1132 } -
trunk/Source/WebInspectorUI/UserInterface/Protocol/InspectorBackend.js
r188283 r188946 136 136 let responseData = {command, callback}; 137 137 138 // FIXME: <https://webkit.org/b/135467> use performance.now() where available.139 138 if (this.dumpInspectorTimeStats) 140 responseData.sendRequestTime = Date.now();139 responseData.sendRequestTimestamp = timestamp(); 141 140 142 141 this._pendingResponses.set(sequenceId, responseData); … … 158 157 let responseData = {command}; 159 158 160 // FIXME: <https://webkit.org/b/135467> use performance.now() where available.161 159 if (this.dumpInspectorTimeStats) 162 responseData.sendRequestTime = Date.now();160 responseData.sendRequestTimestamp = timestamp(); 163 161 164 162 let responsePromise = new Promise(function(resolve, reject) { … … 196 194 let {command, callback, promise} = responseData; 197 195 198 var processingStartTime ;196 var processingStartTimestamp; 199 197 if (this.dumpInspectorTimeStats) 200 processingStartTime = Date.now();198 processingStartTimestamp = timestamp(); 201 199 202 200 if (typeof callback === "function") … … 207 205 console.error("Received a command response without a corresponding callback or promise.", messageObject, command); 208 206 209 var processingDuration = Date.now() - processingStartTime;207 let processingDuration = (timestamp() - processingStartTimestamp).toFixed(3); 210 208 if (this.warnForLongMessageHandling && processingDuration > this.longMessageHandlingThreshold) 211 console.warn("InspectorBackend: took " + processingDuration + "ms to handle response for command: " + command.qualifiedName); 212 213 if (this.dumpInspectorTimeStats) 214 console.log("time-stats: Handling: " + processingDuration + "ms; RTT: " + (processingStartTime - responseData.sendRequestTime) + "ms; (command " + command.qualifiedName + ")"); 209 console.warn(`InspectorBackend: took ${processingDuration}ms to handle response for command: ${command.qualifiedName}`); 210 211 if (this.dumpInspectorTimeStats) { 212 let roundTripDuration = (processingStartTimestamp - responseData.sendRequestTimestamp).toFixed(3); 213 console.log(`time-stats: Handling: ${processingDuration}ms; RTT: ${roundTripDuration}ms; (command ${command.qualifiedName})`); 214 } 215 215 216 216 if (this._deferredScripts.length && !this._pendingResponses.size) … … 272 272 } 273 273 274 var processingStartTime ;274 var processingStartTimestamp; 275 275 if (this.dumpInspectorTimeStats) 276 processingStartTime = Date.now();276 processingStartTimestamp = timestamp(); 277 277 278 278 try { … … 282 282 } 283 283 284 var processingDuration = Date.now() - processingStartTime;284 let processingDuration = (timestamp() - processingStartTimestamp).toFixed(3); 285 285 if (this.warnForLongMessageHandling && processingDuration > this.longMessageHandlingThreshold) 286 console.warn( "InspectorBackend: took " + processingDuration + "ms to handle event: " + messageObject["method"]);286 console.warn(`InspectorBackend: took ${processingDuration}ms to handle event: ${messageObject.method}`); 287 287 288 288 if (this.dumpInspectorTimeStats) 289 console.log( "time-stats: Handling: " + processingDuration + "ms (event " + messageObject["method"] + ")");289 console.log(`time-stats: Handling: ${processingDuration}ms (event ${messageObject.method})`); 290 290 } 291 291 -
trunk/Source/WebInspectorUI/UserInterface/Protocol/MessageDispatcher.js
r182039 r188946 29 29 WebInspector.dispatchNextQueuedMessageFromBackend = function() 30 30 { 31 varstartCount = WebInspector._messagesToDispatch.length;32 var startTime = Date.now();33 vartimeLimitPerRunLoop = 10; // milliseconds31 const startCount = WebInspector._messagesToDispatch.length; 32 const startTimestamp = timestamp(); 33 const timeLimitPerRunLoop = 10; // milliseconds 34 34 35 vari = 0;35 let i = 0; 36 36 for (; i < WebInspector._messagesToDispatch.length; ++i) { 37 37 // Defer remaining messages if we have taken too long. In practice, single 38 38 // messages like Page.getResourceContent blow through the time budget. 39 if ( Date.now() - startTime> timeLimitPerRunLoop)39 if (timestamp() - startTimestamp > timeLimitPerRunLoop) 40 40 break; 41 41 … … 51 51 } 52 52 53 if (InspectorBackend.dumpInspectorTimeStats) 54 console.log("time-stats: --- RunLoop duration: " + (Date.now() - startTime) + "ms; dispatched: " + (startCount - WebInspector._messagesToDispatch.length) + "; remaining: " + WebInspector._messagesToDispatch.length); 53 if (InspectorBackend.dumpInspectorTimeStats) { 54 let messageDuration = (timestamp() - startTimestamp).toFixed(3); 55 let dispatchedCount = startCount - WebInspector._messagesToDispatch.length; 56 let remainingCount = WebInspector._messagesToDispatch.length; 57 console.log(`time-stats: --- RunLoop duration: ${messageDuration}ms; dispatched: ${dispatchedCount}; remaining: ${remainingCount}`); 58 } 55 59 }; 56 60 … … 60 64 // The messages are dequeued on a zero delay timeout. 61 65 62 WebInspector._messagesToDispatch.push(message);66 this._messagesToDispatch.push(message); 63 67 64 68 if (this._dispatchTimeout) 65 69 return; 66 70 67 this._dispatchTimeout = setTimeout( WebInspector.dispatchNextQueuedMessageFromBackend, 0);71 this._dispatchTimeout = setTimeout(this.dispatchNextQueuedMessageFromBackend, 0); 68 72 };
Note: See TracChangeset
for help on using the changeset viewer.