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

Side by Side Diff: Source/devtools/front_end/timeline/TimelineEventOverview.js

Issue 1180843010: DevTools: Optimize events overview drawing performance (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | Source/devtools/front_end/ui_lazy/TimelineOverviewPane.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 var descriptors = WebInspector.TimelineUIUtils.eventDispatchDesciptors() ; 112 var descriptors = WebInspector.TimelineUIUtils.eventDispatchDesciptors() ;
113 /** @type {!Map.<string,!WebInspector.TimelineUIUtils.EventDispatchTypeD escriptor>} */ 113 /** @type {!Map.<string,!WebInspector.TimelineUIUtils.EventDispatchTypeD escriptor>} */
114 var descriptorsByType = new Map(); 114 var descriptorsByType = new Map();
115 var maxPriority = -1; 115 var maxPriority = -1;
116 for (var descriptor of descriptors) { 116 for (var descriptor of descriptors) {
117 for (var type of descriptor.eventTypes) 117 for (var type of descriptor.eventTypes)
118 descriptorsByType.set(type, descriptor); 118 descriptorsByType.set(type, descriptor);
119 maxPriority = Math.max(maxPriority, descriptor.priority); 119 maxPriority = Math.max(maxPriority, descriptor.priority);
120 } 120 }
121 121
122 var /** @const */ minWidth = 2 * window.devicePixelRatio; 122 var devicePixelRatio = window.devicePixelRatio;
123 var stripHeight = height - padding; 123 var /** @const */ minWidth = 2 * devicePixelRatio;
124 var stripHeight = (height - padding) * devicePixelRatio;
124 var timeOffset = this._model.minimumRecordTime(); 125 var timeOffset = this._model.minimumRecordTime();
125 var timeSpan = this._model.maximumRecordTime() - timeOffset; 126 var timeSpan = this._model.maximumRecordTime() - timeOffset;
126 var canvasWidth = this._canvas.width; 127 var canvasWidth = this._canvas.width;
127 var scale = canvasWidth / timeSpan; 128 var scale = canvasWidth / timeSpan;
129 position = (position + padding) * devicePixelRatio;
128 130
129 for (var priority = 0; priority <= maxPriority; ++priority) { 131 for (var priority = 0; priority <= maxPriority; ++priority) {
130 for (var i = 0; i < events.length; ++i) { 132 for (var i = 0; i < events.length; ++i) {
131 var event = events[i]; 133 var event = events[i];
132 if (event.name !== WebInspector.TimelineModel.RecordType.EventDi spatch) 134 if (event.name !== WebInspector.TimelineModel.RecordType.EventDi spatch)
133 continue; 135 continue;
134 var descriptor = descriptorsByType.get(event.args["data"]["type" ]); 136 var descriptor = descriptorsByType.get(event.args["data"]["type" ]);
135 if (!descriptor || descriptor.priority !== priority) 137 if (!descriptor || descriptor.priority !== priority)
136 continue; 138 continue;
137 var start = Number.constrain(Math.floor((event.startTime - timeO ffset) * scale), 0, canvasWidth); 139 var start = Number.constrain(Math.floor((event.startTime - timeO ffset) * scale), 0, canvasWidth);
138 var end = Number.constrain(Math.ceil((event.endTime - timeOffset ) * scale), 0, canvasWidth); 140 var end = Number.constrain(Math.ceil((event.endTime - timeOffset ) * scale), 0, canvasWidth);
139 var width = Math.max(end - start, minWidth); 141 var width = Math.max(end - start, minWidth);
140 this._renderBar(start, start + width, position + padding, stripH eight, descriptor.color); 142 this._renderBar(start, start + width, position, stripHeight, des criptor.color);
141 } 143 }
142 } 144 }
143 145
144 return height; 146 return height;
145 }, 147 },
146 148
147 /** 149 /**
148 * @param {!Array.<!WebInspector.TracingModel.Event>} events 150 * @param {!Array.<!WebInspector.TracingModel.Event>} events
149 * @param {number} position 151 * @param {number} position
150 * @param {number} height 152 * @param {number} height
151 * @return {number} 153 * @return {number}
152 */ 154 */
153 _drawNetwork: function(events, position, height) 155 _drawNetwork: function(events, position, height)
154 { 156 {
155 var /** @const */ padding = 1; 157 var /** @const */ padding = 1;
156 var /** @const */ maxBandHeight = 4; 158 var /** @const */ maxBandHeight = 4;
157 position += padding; 159 position += padding;
160 var devicePixelRatio = window.devicePixelRatio;
158 var bandsCount = WebInspector.TimelineUIUtils.calculateNetworkBandsCount (events); 161 var bandsCount = WebInspector.TimelineUIUtils.calculateNetworkBandsCount (events);
159 var bandInterval = Math.min(maxBandHeight, (height - padding) / (bandsCo unt || 1)); 162 var bandInterval = Math.min(maxBandHeight, (height - padding) / (bandsCo unt || 1));
160 var bandHeight = Math.ceil(bandInterval); 163 var bandHeight = Math.ceil(bandInterval * devicePixelRatio);
161 var timeOffset = this._model.minimumRecordTime(); 164 var timeOffset = this._model.minimumRecordTime();
162 var timeSpan = this._model.maximumRecordTime() - timeOffset; 165 var timeSpan = this._model.maximumRecordTime() - timeOffset;
163 var canvasWidth = this._canvas.width; 166 var canvasWidth = this._canvas.width;
164 var scale = canvasWidth / timeSpan; 167 var scale = canvasWidth / timeSpan;
165 var loadingCategory = WebInspector.TimelineUIUtils.categories()["loading "]; 168 var loadingCategory = WebInspector.TimelineUIUtils.categories()["loading "];
166 var waitingColor = loadingCategory.backgroundColor; 169 var waitingColor = loadingCategory.backgroundColor;
167 var processingColor = loadingCategory.fillColorStop1; 170 var processingColor = loadingCategory.fillColorStop1;
168 171
169 /** 172 /**
170 * @param {number} band 173 * @param {number} band
171 * @param {number} startTime 174 * @param {number} startTime
172 * @param {number} endTime 175 * @param {number} endTime
173 * @param {?WebInspector.TracingModel.Event} event 176 * @param {?WebInspector.TracingModel.Event} event
174 * @this {WebInspector.TimelineEventOverview} 177 * @this {WebInspector.TimelineEventOverview}
175 */ 178 */
176 function drawBar(band, startTime, endTime, event) 179 function drawBar(band, startTime, endTime, event)
177 { 180 {
178 var start = Number.constrain((startTime - timeOffset) * scale, 0, ca nvasWidth); 181 var start = Number.constrain((startTime - timeOffset) * scale, 0, ca nvasWidth);
179 var end = Number.constrain((endTime - timeOffset) * scale, 0, canvas Width); 182 var end = Number.constrain((endTime - timeOffset) * scale, 0, canvas Width);
180 var color = !event || 183 var color = !event ||
181 event.name === WebInspector.TimelineModel.RecordType.ResourceRec eiveResponse || 184 event.name === WebInspector.TimelineModel.RecordType.ResourceRec eiveResponse ||
182 event.name === WebInspector.TimelineModel.RecordType.ResourceSen dRequest ? waitingColor : processingColor; 185 event.name === WebInspector.TimelineModel.RecordType.ResourceSen dRequest ? waitingColor : processingColor;
183 this._renderBar(Math.floor(start), Math.ceil(end), Math.floor(positi on + band * bandInterval), bandHeight, color); 186 this._renderBar(Math.floor(start), Math.ceil(end), Math.floor(device PixelRatio * (position + band * bandInterval)), bandHeight, color);
184 } 187 }
185 188
186 WebInspector.TimelineUIUtils.iterateNetworkRequestsInRoundRobin(events, bandsCount, drawBar.bind(this)); 189 WebInspector.TimelineUIUtils.iterateNetworkRequestsInRoundRobin(events, bandsCount, drawBar.bind(this));
187 return height; 190 return height;
188 }, 191 },
189 192
190 /** 193 /**
191 * @param {!Array.<!WebInspector.TracingModel.Event>} events 194 * @param {!Array.<!WebInspector.TracingModel.Event>} events
192 * @param {number} position 195 * @param {number} position
193 * @param {number} height 196 * @param {number} height
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 265
263 /** 266 /**
264 * @param {!Array.<!WebInspector.TracingModel.Event>} events 267 * @param {!Array.<!WebInspector.TracingModel.Event>} events
265 * @param {number} position 268 * @param {number} position
266 * @param {number} stripHeight 269 * @param {number} stripHeight
267 * @return {number} 270 * @return {number}
268 */ 271 */
269 _drawEvents: function(events, position, stripHeight) 272 _drawEvents: function(events, position, stripHeight)
270 { 273 {
271 var /** @const */ padding = 1; 274 var /** @const */ padding = 1;
272 var visualHeight = stripHeight - padding; 275 var visualHeight = (stripHeight - padding) * window.devicePixelRatio;
273 var timeOffset = this._model.minimumRecordTime(); 276 var timeOffset = this._model.minimumRecordTime();
274 var timeSpan = this._model.maximumRecordTime() - timeOffset; 277 var timeSpan = this._model.maximumRecordTime() - timeOffset;
275 var scale = this._canvas.width / timeSpan; 278 var scale = this._canvas.width / timeSpan;
276 var ditherer = new WebInspector.Dithering(); 279 var ditherer = new WebInspector.Dithering();
277 var categoryStack = []; 280 var categoryStack = [];
278 var lastX = 0; 281 var lastX = 0;
279 position += padding; 282 position += padding;
283 position *= window.devicePixelRatio;
280 284
281 /** 285 /**
282 * @param {!WebInspector.TracingModel.Event} e 286 * @param {!WebInspector.TracingModel.Event} e
283 * @this {WebInspector.TimelineEventOverview} 287 * @this {WebInspector.TimelineEventOverview}
284 */ 288 */
285 function onEventStart(e) 289 function onEventStart(e)
286 { 290 {
287 var pos = (e.startTime - timeOffset) * scale; 291 var pos = (e.startTime - timeOffset) * scale;
288 if (categoryStack.length) { 292 if (categoryStack.length) {
289 var category = categoryStack.peekLast(); 293 var category = categoryStack.peekLast();
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 /** 437 /**
434 * @param {number} begin 438 * @param {number} begin
435 * @param {number} end 439 * @param {number} end
436 * @param {number} position 440 * @param {number} position
437 * @param {number} height 441 * @param {number} height
438 * @param {string} color 442 * @param {string} color
439 */ 443 */
440 _renderBar: function(begin, end, position, height, color) 444 _renderBar: function(begin, end, position, height, color)
441 { 445 {
442 var x = begin; 446 var x = begin;
443 var y = position * window.devicePixelRatio;
444 var width = end - begin; 447 var width = end - begin;
445 this._context.fillStyle = color; 448 this._context.fillStyle = color;
446 this._context.fillRect(x, y, width, height * window.devicePixelRatio); 449 this._context.fillRect(x, position, width, height);
447 }, 450 },
448 451
449 /** 452 /**
450 * @override 453 * @override
451 * @param {number} windowLeft 454 * @param {number} windowLeft
452 * @param {number} windowRight 455 * @param {number} windowRight
453 * @return {!{startTime: number, endTime: number}} 456 * @return {!{startTime: number, endTime: number}}
454 */ 457 */
455 windowTimes: function(windowLeft, windowRight) 458 windowTimes: function(windowLeft, windowRight)
456 { 459 {
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 counters[group] = this._quantDuration; 600 counters[group] = this._quantDuration;
598 this._callback(counters); 601 this._callback(counters);
599 interval -= this._quantDuration; 602 interval -= this._quantDuration;
600 } 603 }
601 this._counters = []; 604 this._counters = [];
602 this._counters[group] = interval; 605 this._counters[group] = interval;
603 this._lastTime = time; 606 this._lastTime = time;
604 this._remainder = this._quantDuration - interval; 607 this._remainder = this._quantDuration - interval;
605 } 608 }
606 } 609 }
OLDNEW
« no previous file with comments | « no previous file | Source/devtools/front_end/ui_lazy/TimelineOverviewPane.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698