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

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

Issue 1144963002: Timeline: visually distinguish idle frames (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebased / adjusted to chrome-side changes in instrumentation 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 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 * @param {!Array.<!WebInspector.TimelineFrame>} frames 195 * @param {!Array.<!WebInspector.TimelineFrame>} frames
196 * @param {number} framesPerBar 196 * @param {number} framesPerBar
197 * @return {!Array.<!WebInspector.TimelineFrame>} 197 * @return {!Array.<!WebInspector.TimelineFrame>}
198 */ 198 */
199 _aggregateFrames: function(frames, framesPerBar) 199 _aggregateFrames: function(frames, framesPerBar)
200 { 200 {
201 var visibleFrames = []; 201 var visibleFrames = [];
202 for (var barIndex = 0, currentFrame = 0; currentFrame < frames.length; + +barIndex) { 202 for (var barIndex = 0, currentFrame = 0; currentFrame < frames.length; + +barIndex) {
203 var barStartTime = frames[currentFrame].startTime; 203 var barStartTime = frames[currentFrame].startTime;
204 var longestFrame = null; 204 var longestFrame = null;
205 var longestDuration = 0; 205 var longestDuration = -Infinity;
alph 2015/06/05 16:55:39 nit: the initial value doesn't really matter.
206 206
207 for (var lastFrame = Math.min(Math.floor((barIndex + 1) * framesPerB ar), frames.length); 207 for (var lastFrame = Math.min(Math.floor((barIndex + 1) * framesPerB ar), frames.length);
208 currentFrame < lastFrame; ++currentFrame) { 208 currentFrame < lastFrame; ++currentFrame) {
209 var duration = frames[currentFrame].duration; 209 var frame = frames[currentFrame];
210 var duration = frame.idle ? 0 : frame.duration; // Only consider idle frames if there are no regular frames.
210 if (!longestFrame || longestDuration < duration) { 211 if (!longestFrame || longestDuration < duration) {
211 longestFrame = frames[currentFrame]; 212 longestFrame = frame;
212 longestDuration = duration; 213 longestDuration = duration;
213 } 214 }
214 } 215 }
215 var barEndTime = frames[currentFrame - 1].endTime; 216 var barEndTime = frames[currentFrame - 1].endTime;
216 if (longestFrame) { 217 if (longestFrame) {
217 visibleFrames.push(longestFrame); 218 visibleFrames.push(longestFrame);
218 this._barTimes.push({ startTime: barStartTime, endTime: barEndTi me }); 219 this._barTimes.push({ startTime: barStartTime, endTime: barEndTi me });
219 } 220 }
220 } 221 }
221 return visibleFrames; 222 return visibleFrames;
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 this._context.fillRect(0, y, this._maxInnerBarWidth, Math.floor(heig ht)); 345 this._context.fillRect(0, y, this._maxInnerBarWidth, Math.floor(heig ht));
345 this._context.strokeStyle = WebInspector.TimelineUIUtils.categories( )[category].borderColor; 346 this._context.strokeStyle = WebInspector.TimelineUIUtils.categories( )[category].borderColor;
346 this._context.beginPath(); 347 this._context.beginPath();
347 this._context.moveTo(0, y); 348 this._context.moveTo(0, y);
348 this._context.lineTo(this._maxInnerBarWidth, y); 349 this._context.lineTo(this._maxInnerBarWidth, y);
349 this._context.stroke(); 350 this._context.stroke();
350 this._context.restore(); 351 this._context.restore();
351 352
352 bottomOffset -= height; 353 bottomOffset -= height;
353 } 354 }
355 // Skip outline for idle frames, unless frame is selected.
356 if (frame.idle && index !== this._activeBarIndex)
357 return;
358
354 // Draw a contour for the total frame time. 359 // Draw a contour for the total frame time.
355 var y0 = Math.floor(windowHeight - frame.duration * this._scale) + 0.5; 360 var y0 = frame.idle ? bottomOffset + 0.5 : Math.floor(windowHeight - fra me.duration * this._scale) + 0.5;
356 var y1 = windowHeight + 0.5; 361 var y1 = windowHeight + 0.5;
357 362
358 this._context.strokeStyle = index === this._activeBarIndex ? "rgba(0, 0, 0, 0.6)" : "rgba(90, 90, 90, 0.2)"; 363 this._context.strokeStyle = index === this._activeBarIndex ? "rgba(0, 0, 0, 0.6)" : "rgba(90, 90, 90, 0.2)";
359 this._context.beginPath(); 364 this._context.beginPath();
360 this._context.moveTo(x, y1); 365 this._context.moveTo(x, y1);
361 this._context.lineTo(x, y0); 366 this._context.lineTo(x, y0);
362 this._context.lineTo(x + width, y0); 367 this._context.lineTo(x + width, y0);
363 this._context.lineTo(x + width, y1); 368 this._context.lineTo(x + width, y1);
364 this._context.stroke(); 369 this._context.stroke();
365 }, 370 },
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 * @param {number} time 467 * @param {number} time
463 * @param {function(number, {startTime:number, endTime:number}):number} comp arator 468 * @param {function(number, {startTime:number, endTime:number}):number} comp arator
464 */ 469 */
465 _firstBarAfter: function(time, comparator) 470 _firstBarAfter: function(time, comparator)
466 { 471 {
467 return insertionIndexForObjectInListSortedByFunction(time, this._barTime s, comparator); 472 return insertionIndexForObjectInListSortedByFunction(time, this._barTime s, comparator);
468 }, 473 },
469 474
470 __proto__: WebInspector.TimelineOverviewBase.prototype 475 __proto__: WebInspector.TimelineOverviewBase.prototype
471 } 476 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698