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

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

Issue 305623007: Add aggregated stats to selected trace event details (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Addressed comment Created 6 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 | 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) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * Copyright (C) 2012 Intel Inc. All rights reserved. 3 * Copyright (C) 2012 Intel Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after
730 * @param {?Element} imagePreviewElement 730 * @param {?Element} imagePreviewElement
731 * @param {?WebInspector.DOMNode} relatedNode 731 * @param {?WebInspector.DOMNode} relatedNode
732 * @param {boolean} loadedFromFile 732 * @param {boolean} loadedFromFile
733 * @param {?WebInspector.TimelineTraceEventBindings} bindings 733 * @param {?WebInspector.TimelineTraceEventBindings} bindings
734 * @param {!WebInspector.Target} target 734 * @param {!WebInspector.Target} target
735 * @return {!DocumentFragment} 735 * @return {!DocumentFragment}
736 */ 736 */
737 WebInspector.TimelineUIUtils._buildTraceEventDetailsSynchronously = function(eve nt, model, linkifier, imagePreviewElement, relatedNode, loadedFromFile, bindings , target) 737 WebInspector.TimelineUIUtils._buildTraceEventDetailsSynchronously = function(eve nt, model, linkifier, imagePreviewElement, relatedNode, loadedFromFile, bindings , target)
738 { 738 {
739 var fragment = document.createDocumentFragment(); 739 var fragment = document.createDocumentFragment();
740 var stats = WebInspector.TimelineUIUtils._aggregatedStatsForTraceEvent(model , event);
741 fragment.appendChild(WebInspector.TimelineUIUtils.generatePieChart(stats));
742
740 var recordTypes = WebInspector.TimelineModel.RecordType; 743 var recordTypes = WebInspector.TimelineModel.RecordType;
741 744
742 // The messages may vary per event.name; 745 // The messages may vary per event.name;
743 var callSiteStackTraceLabel; 746 var callSiteStackTraceLabel;
744 var callStackLabel; 747 var callStackLabel;
745 var relatedNodeLabel; 748 var relatedNodeLabel;
746 749
747 var contentHelper = new WebInspector.TimelineDetailsContentHelper(target, li nkifier, true); 750 var contentHelper = new WebInspector.TimelineDetailsContentHelper(target, li nkifier, true);
748 contentHelper.appendTextRow(WebInspector.UIString("Self Time"), Number.milli sToString(event.selfTime / 1000, true)); 751 contentHelper.appendTextRow(WebInspector.UIString("Self Time"), Number.milli sToString(event.selfTime / 1000, true));
749 contentHelper.appendTextRow(WebInspector.UIString("Start Time"), Number.mill isToString((event.startTime - model.minimumRecordTime()) / 1000)); 752 contentHelper.appendTextRow(WebInspector.UIString("Start Time"), Number.mill isToString((event.startTime - model.minimumRecordTime()) / 1000));
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
876 if (warning) { 879 if (warning) {
877 var div = document.createElement("div"); 880 var div = document.createElement("div");
878 div.textContent = warning; 881 div.textContent = warning;
879 contentHelper.appendElementRow(WebInspector.UIString("Warning"), div); 882 contentHelper.appendElementRow(WebInspector.UIString("Warning"), div);
880 } 883 }
881 fragment.appendChild(contentHelper.element); 884 fragment.appendChild(contentHelper.element);
882 return fragment; 885 return fragment;
883 } 886 }
884 887
885 /** 888 /**
889 * @param {!WebInspector.TracingModel} model
890 * @param {!WebInspector.TracingModel.Event} event
891 * @return {!Object}
892 */
893 WebInspector.TimelineUIUtils._aggregatedStatsForTraceEvent = function(model, eve nt)
894 {
895 var events = model.inspectedTargetEvents();
896 /**
897 * @param {number} startTime
898 * @param {!WebInspector.TracingModel.Event} e
899 * @return {number}
900 */
901 function eventComparator(startTime, e)
902 {
903 return startTime - e.startTime;
904 }
905 var index = events.binaryIndexOf(event.startTime, eventComparator);
906 var aggregatedStats = {};
907 var endTime = event.endTime;
908 if (!endTime)
909 return aggregatedStats;
910 for (; index < events.length; index++) {
911 var nextEvent = events[index];
912 if (nextEvent.startTime > endTime)
913 break;
914 if (!nextEvent.selfTime)
915 continue;
916 var category = WebInspector.TimelineUIUtils.styleForTimelineEvent(nextEv ent.name).category.name;
917 aggregatedStats[category] = (aggregatedStats[category] || 0) + nextEvent .selfTime;
918 }
919 return aggregatedStats;
920 }
921
922 /**
886 * @param {!Array.<number>} quad 923 * @param {!Array.<number>} quad
887 * @return {number} 924 * @return {number}
888 */ 925 */
889 WebInspector.TimelineUIUtils._quadHeight = function(quad) 926 WebInspector.TimelineUIUtils._quadHeight = function(quad)
890 { 927 {
891 return Math.round(Math.sqrt(Math.pow(quad[0] - quad[6], 2) + Math.pow(quad[1 ] - quad[7], 2))); 928 return Math.round(Math.sqrt(Math.pow(quad[0] - quad[6], 2) + Math.pow(quad[1 ] - quad[7], 2)));
892 } 929 }
893 930
894 /** 931 /**
895 * @param {!WebInspector.TimelineModel.Record} record 932 * @param {!WebInspector.TimelineModel.Record} record
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
1342 for (var i = 0; i < stackTrace.length; ++i) { 1379 for (var i = 0; i < stackTrace.length; ++i) {
1343 var stackFrame = stackTrace[i]; 1380 var stackFrame = stackTrace[i];
1344 var row = stackTraceElement.createChild("div"); 1381 var row = stackTraceElement.createChild("div");
1345 row.createTextChild(stackFrame.functionName || WebInspector.UIString ("(anonymous function)")); 1382 row.createTextChild(stackFrame.functionName || WebInspector.UIString ("(anonymous function)"));
1346 row.createTextChild(" @ "); 1383 row.createTextChild(" @ ");
1347 var urlElement = this._linkifier.linkifyLocation(this._target, stack Frame.url, stackFrame.lineNumber - 1); 1384 var urlElement = this._linkifier.linkifyLocation(this._target, stack Frame.url, stackFrame.lineNumber - 1);
1348 row.appendChild(urlElement); 1385 row.appendChild(urlElement);
1349 } 1386 }
1350 } 1387 }
1351 } 1388 }
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