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

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

Issue 405563003: DevTools: Do not add stack traces twice on nested events in timeline (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 5 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 | no next file » | 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) 2014 Google Inc. All rights reserved. 2 * Copyright (C) 2014 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 557 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 }, 568 },
569 569
570 /** 570 /**
571 * @param {string} headerName 571 * @param {string} headerName
572 * @param {!Array.<!WebInspector.TracingModel.Event>} events 572 * @param {!Array.<!WebInspector.TracingModel.Event>} events
573 */ 573 */
574 _appendThreadTimelineData: function(headerName, events) 574 _appendThreadTimelineData: function(headerName, events)
575 { 575 {
576 var maxStackDepth = 0; 576 var maxStackDepth = 0;
577 var openEvents = []; 577 var openEvents = [];
578 var heights = []; 578 var levels = [];
579 var jsHeights = [];
579 var headerAppended = false; 580 var headerAppended = false;
580 var level = 0; 581 var level = 0;
582 var jsStackHeight = 0;
581 for (var i = 0; i < events.length; ++i) { 583 for (var i = 0; i < events.length; ++i) {
582 var e = events[i]; 584 var e = events[i];
583 if (!e.endTime && e.phase !== WebInspector.TracingModel.Phase.Instan t) 585 if (!e.endTime && e.phase !== WebInspector.TracingModel.Phase.Instan t)
584 continue; 586 continue;
585 if (!this._isVisible(e)) 587 if (!this._isVisible(e))
586 continue; 588 continue;
587 while (openEvents.length && openEvents.peekLast().endTime <= e.start Time) { 589 while (openEvents.length && openEvents.peekLast().endTime <= e.start Time) {
588 openEvents.pop(); 590 openEvents.pop();
589 level = heights.pop(); 591 level = levels.pop();
592 jsStackHeight = jsHeights.pop();
590 } 593 }
591 if (!headerAppended) { 594 if (!headerAppended) {
592 this._appendHeaderRecord(headerName, this._currentLevel); 595 this._appendHeaderRecord(headerName, this._currentLevel);
593 ++level; 596 ++level;
594 headerAppended = true; 597 headerAppended = true;
595 } 598 }
596 var height = this._processEvent(e, this._currentLevel + level); 599 var jsHeightDelta = this._processEvent(e, this._currentLevel + level , jsStackHeight);
597 if (e.endTime) { 600 if (e.endTime) {
598 openEvents.push(e); 601 openEvents.push(e);
599 heights.push(level) 602 jsHeights.push(jsStackHeight);
603 levels.push(level);
600 } 604 }
601 level += height; 605 level += 1 + jsHeightDelta;
606 jsStackHeight += jsHeightDelta;
602 maxStackDepth = Math.max(maxStackDepth, level); 607 maxStackDepth = Math.max(maxStackDepth, level);
603 } 608 }
604 this._currentLevel += maxStackDepth; 609 this._currentLevel += maxStackDepth;
605 }, 610 },
606 611
607 /** 612 /**
608 * @param {!WebInspector.TracingModel.Event} event 613 * @param {!WebInspector.TracingModel.Event} event
609 * @param {number} baseLevel 614 * @param {number} level
615 * @param {number} jsStackHeight
610 * @return {number} 616 * @return {number}
611 */ 617 */
612 _processEvent: function(event, baseLevel) 618 _processEvent: function(event, level, jsStackHeight)
613 { 619 {
614 var level = baseLevel;
615 if (event.stackTrace && WebInspector.experimentsSettings.timelineJSCPUPr ofile.isEnabled()) { 620 if (event.stackTrace && WebInspector.experimentsSettings.timelineJSCPUPr ofile.isEnabled()) {
616 for (var i = event.stackTrace.length - 1; i >= 0; --i) { 621 for (var i = event.stackTrace.length - 1; i >= jsStackHeight; --i) {
617 var payload = /** @type {!WebInspector.TracingModel.EventPayload } */ ({ 622 var payload = /** @type {!WebInspector.TracingModel.EventPayload } */ ({
618 ph: WebInspector.TracingModel.Phase.Complete, 623 ph: WebInspector.TracingModel.Phase.Complete,
619 cat: WebInspector.TracingModel.DevToolsMetadataEventCategory , 624 cat: WebInspector.TracingModel.DevToolsMetadataEventCategory ,
620 name: WebInspector.TracingTimelineModel.RecordType.JSFrame, 625 name: WebInspector.TracingTimelineModel.RecordType.JSFrame,
621 ts: event.startTime * 1000, 626 ts: event.startTime * 1000,
622 dur: event.duration * 1000, 627 dur: event.duration * 1000,
623 args: { 628 args: {
624 data: event.stackTrace[i] 629 data: event.stackTrace[i]
625 } 630 }
626 }); 631 });
627 var jsFrameEvent = new WebInspector.TracingModel.Event(payload, 0, event.thread); 632 var jsFrameEvent = new WebInspector.TracingModel.Event(payload, 0, event.thread);
628 this._appendEvent(jsFrameEvent, level++); 633 this._appendEvent(jsFrameEvent, level++);
629 } 634 }
630 } 635 }
631 this._appendEvent(event, level++) 636 this._appendEvent(event, level)
632 return level - baseLevel; 637 return event.stackTrace ? event.stackTrace.length - jsStackHeight : 0;
yurys 2014/07/18 11:16:19 You should always return 0 if the experiment is of
alph 2014/07/18 11:21:57 Good catch!
633 }, 638 },
634 639
635 /** 640 /**
636 * @param {!WebInspector.TracingTimelineModel.Filter} filter 641 * @param {!WebInspector.TracingTimelineModel.Filter} filter
637 */ 642 */
638 addFilter: function(filter) 643 addFilter: function(filter)
639 { 644 {
640 this._filters.push(filter); 645 this._filters.push(filter);
641 }, 646 },
642 647
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
1054 * @param {number} entryIndex 1059 * @param {number} entryIndex
1055 * @return {?WebInspector.TimelineSelection} 1060 * @return {?WebInspector.TimelineSelection}
1056 */ 1061 */
1057 createSelection: function(entryIndex) { }, 1062 createSelection: function(entryIndex) { },
1058 /** 1063 /**
1059 * @param {?WebInspector.TimelineSelection} selection 1064 * @param {?WebInspector.TimelineSelection} selection
1060 * @return {number} 1065 * @return {number}
1061 */ 1066 */
1062 entryIndexForSelection: function(selection) { } 1067 entryIndexForSelection: function(selection) { }
1063 } 1068 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698