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

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

Issue 1155963005: DevTools: Show frame rate on timeline events overview. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
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
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 14 matching lines...) Expand all
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 /** 31 /**
32 * @constructor 32 * @constructor
33 * @extends {WebInspector.TimelineOverviewBase} 33 * @extends {WebInspector.TimelineOverviewBase}
34 * @param {!WebInspector.TimelineModel} model 34 * @param {!WebInspector.TimelineModel} model
35 * @param {!WebInspector.TimelineFrameModelBase} frameModel
35 */ 36 */
36 WebInspector.TimelineEventOverview = function(model) 37 WebInspector.TimelineEventOverview = function(model, frameModel)
37 { 38 {
38 WebInspector.TimelineOverviewBase.call(this, model); 39 WebInspector.TimelineOverviewBase.call(this, model);
39 this.element.id = "timeline-overview-events"; 40 this.element.id = "timeline-overview-events";
41 this._frameModel = frameModel;
40 42
41 this._fillStyles = {}; 43 this._fillStyles = {};
42 var categories = WebInspector.TimelineUIUtils.categories(); 44 var categories = WebInspector.TimelineUIUtils.categories();
43 for (var category in categories) { 45 for (var category in categories) {
44 this._fillStyles[category] = categories[category].fillColorStop1; 46 this._fillStyles[category] = categories[category].fillColorStop1;
45 categories[category].addEventListener(WebInspector.TimelineCategory.Even ts.VisibilityChanged, this._onCategoryVisibilityChanged, this); 47 categories[category].addEventListener(WebInspector.TimelineCategory.Even ts.VisibilityChanged, this._onCategoryVisibilityChanged, this);
46 } 48 }
47 49
48 this._disabledCategoryFillStyle = "hsl(0, 0%, 67%)"; 50 this._disabledCategoryFillStyle = "hsl(0, 0%, 67%)";
49 } 51 }
50 52
51 /** @const */ 53 /** @const */
52 WebInspector.TimelineEventOverview._mainStripHeight = 16; 54 WebInspector.TimelineEventOverview._fullStripHeight = 16;
53 /** @const */ 55 /** @const */
54 WebInspector.TimelineEventOverview._smallStripHeight = 8; 56 WebInspector.TimelineEventOverview._smallStripHeight = 8;
55 57
56 WebInspector.TimelineEventOverview.prototype = { 58 WebInspector.TimelineEventOverview.prototype = {
57 /** 59 /**
58 * @override 60 * @override
59 */ 61 */
60 dispose: function() 62 dispose: function()
61 { 63 {
62 WebInspector.TimelineOverviewBase.prototype.dispose.call(this); 64 WebInspector.TimelineOverviewBase.prototype.dispose.call(this);
63 var categories = WebInspector.TimelineUIUtils.categories(); 65 var categories = WebInspector.TimelineUIUtils.categories();
64 for (var category in categories) 66 for (var category in categories)
65 categories[category].removeEventListener(WebInspector.TimelineCatego ry.Events.VisibilityChanged, this._onCategoryVisibilityChanged, this); 67 categories[category].removeEventListener(WebInspector.TimelineCatego ry.Events.VisibilityChanged, this._onCategoryVisibilityChanged, this);
66 }, 68 },
67 69
68 /** 70 /**
69 * @override 71 * @override
70 */ 72 */
71 update: function() 73 update: function()
72 { 74 {
73 this.resetCanvas(); 75 this.resetCanvas();
74 var threads = this._model.virtualThreads(); 76 var threads = this._model.virtualThreads();
75 var mainThreadEvents = this._model.mainThreadEvents(); 77 var mainThreadEvents = this._model.mainThreadEvents();
76 var networkHeight = this._canvas.clientHeight 78 var networkHeight = this._canvas.clientHeight
77 - WebInspector.TimelineEventOverview._mainStripHeight 79 - WebInspector.TimelineEventOverview._fullStripHeight
78 - 2 * WebInspector.TimelineEventOverview._smallStripHeight; 80 - 2 * WebInspector.TimelineEventOverview._smallStripHeight;
79 var position = 0; 81 var position = 0;
80 if (Runtime.experiments.isEnabled("inputEventsOnTimelineOverview")) { 82 if (Runtime.experiments.isEnabled("inputEventsOnTimelineOverview")) {
81 var inputHeight = this._drawInputEvents(mainThreadEvents, position, WebInspector.TimelineEventOverview._smallStripHeight); 83 var inputHeight = this._drawInputEvents(mainThreadEvents, position, WebInspector.TimelineEventOverview._smallStripHeight);
82 position += inputHeight; 84 position += inputHeight;
83 networkHeight -= inputHeight; 85 networkHeight -= inputHeight;
84 } 86 }
87 if (Runtime.experiments.isEnabled("frameRateOnEventsOverview"))
88 networkHeight -= WebInspector.TimelineEventOverview._fullStripHeight ;
85 position += this._drawNetwork(mainThreadEvents, position, networkHeight) ; 89 position += this._drawNetwork(mainThreadEvents, position, networkHeight) ;
86 position += this._drawEvents(mainThreadEvents, position, WebInspector.Ti melineEventOverview._mainStripHeight); 90 if (Runtime.experiments.isEnabled("frameRateOnEventsOverview"))
91 position += this._drawFrames(position, WebInspector.TimelineEventOve rview._fullStripHeight);
92 position += this._drawEvents(mainThreadEvents, position, WebInspector.Ti melineEventOverview._fullStripHeight);
87 for (var thread of threads.filter(function(thread) { return !thread.isWo rker(); })) 93 for (var thread of threads.filter(function(thread) { return !thread.isWo rker(); }))
88 this._drawEvents(thread.events, position, WebInspector.TimelineEvent Overview._smallStripHeight); 94 this._drawEvents(thread.events, position, WebInspector.TimelineEvent Overview._smallStripHeight);
89 position += WebInspector.TimelineEventOverview._smallStripHeight; 95 position += WebInspector.TimelineEventOverview._smallStripHeight;
90 for (var thread of threads.filter(function(thread) { return thread.isWor ker(); })) 96 for (var thread of threads.filter(function(thread) { return thread.isWor ker(); }))
91 this._drawEvents(thread.events, position, WebInspector.TimelineEvent Overview._smallStripHeight); 97 this._drawEvents(thread.events, position, WebInspector.TimelineEvent Overview._smallStripHeight);
92 position += WebInspector.TimelineEventOverview._smallStripHeight; 98 position += WebInspector.TimelineEventOverview._smallStripHeight;
93 console.assert(position === this._canvas.clientHeight); 99 console.assert(position === this._canvas.clientHeight);
94 }, 100 },
95 101
96 /** 102 /**
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 var bar = ditherer.appendInterval(category, lastX, pos); 242 var bar = ditherer.appendInterval(category, lastX, pos);
237 if (bar) 243 if (bar)
238 this._renderBar(bar.start, bar.end, position, visualHeight, cate goryColor.call(this, category)); 244 this._renderBar(bar.start, bar.end, position, visualHeight, cate goryColor.call(this, category));
239 lastX = pos; 245 lastX = pos;
240 } 246 }
241 247
242 WebInspector.TimelineModel.forEachEvent(events, onEventStart.bind(this), onEventEnd.bind(this)); 248 WebInspector.TimelineModel.forEachEvent(events, onEventStart.bind(this), onEventEnd.bind(this));
243 return stripHeight; 249 return stripHeight;
244 }, 250 },
245 251
252 /**
253 * @param {number} position
254 * @param {number} height
255 * @return {number}
256 */
257 _drawFrames: function(position, height)
258 {
259 var /** @const */ padding = 2;
260 var /** @const */ baseFrameDurationMs = 1e3 / 60;
261 var visualHeight = (height - padding) * window.devicePixelRatio;
262 var timeOffset = this._model.minimumRecordTime();
263 var timeSpan = this._model.maximumRecordTime() - timeOffset;
264 var scale = this._canvas.width / timeSpan;
265 var frames = this._frameModel.frames();
266 var baseY = (position + height) * window.devicePixelRatio;
267 var y = baseY + 10;
268 var ctx = this._context;
269 ctx.save();
270 ctx.beginPath();
271 ctx.rect(0, position * window.devicePixelRatio, this._canvas.width, heig ht * window.devicePixelRatio);
272 ctx.clip();
273 ctx.beginPath();
274 ctx.lineWidth = 1 * window.devicePixelRatio;
275 ctx.strokeStyle = "hsl(110, 50%, 60%)";
276 ctx.fillStyle = "hsl(110, 50%, 70%)";
277 ctx.moveTo(0, y);
278 for (var i = 0; i < frames.length; ++i) {
279 var frame = frames[i];
280 var x = 0.5 + Math.round((frame.startTime - timeOffset) * scale);
281 ctx.lineTo(x, y);
282 y = 0.5 + Math.round(baseY - visualHeight * Math.min(baseFrameDurati onMs / frame.duration, 1));
yurys 2015/06/05 08:26:28 Can it happen that we have >60fps and the bar woul
alph 2015/06/05 08:54:23 That's why there's a Math.min
283 ctx.lineTo(x, y);
284 }
285 ctx.lineTo(this._canvas.width, y);
286 ctx.lineTo(this._canvas.width, baseY + 10);
287 ctx.closePath();
288 ctx.stroke();
289 ctx.fill();
290 ctx.restore();
291 return height;
292 },
293
246 _onCategoryVisibilityChanged: function() 294 _onCategoryVisibilityChanged: function()
247 { 295 {
248 this.update(); 296 this.update();
249 }, 297 },
250 298
251 /** 299 /**
252 * @param {number} begin 300 * @param {number} begin
253 * @param {number} end 301 * @param {number} end
254 * @param {number} position 302 * @param {number} position
255 * @param {number} height 303 * @param {number} height
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 for (var g of this._groupError.keys()) { 385 for (var g of this._groupError.keys()) {
338 if (!g) 386 if (!g)
339 continue; 387 continue;
340 var value = this._groupError.get(g); 388 var value = this._groupError.get(g);
341 value += (1 - value) * ratio; 389 value += (1 - value) * ratio;
342 this._groupError.set(g, value); 390 this._groupError.set(g, value);
343 } 391 }
344 return toDistribute; 392 return toDistribute;
345 } 393 }
346 } 394 }
OLDNEW
« no previous file with comments | « Source/devtools/front_end/main/Main.js ('k') | Source/devtools/front_end/timeline/TimelinePanel.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698