| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 'use strict'; |
| 5 | 6 |
| 6 /** | 7 /** |
| 7 * @fileoverview TimelineModel is a parsed representation of the | 8 * @fileoverview TimelineModel is a parsed representation of the |
| 8 * TraceEvents obtained from base/trace_event in which the begin-end | 9 * TraceEvents obtained from base/trace_event in which the begin-end |
| 9 * tokens are converted into a hierarchy of processes, threads, | 10 * tokens are converted into a hierarchy of processes, threads, |
| 10 * subrows, and slices. | 11 * subrows, and slices. |
| 11 * | 12 * |
| 12 * The building block of the model is a slice. A slice is roughly | 13 * The building block of the model is a slice. A slice is roughly |
| 13 * equivalent to function call executing on a specific thread. As a | 14 * equivalent to function call executing on a specific thread. As a |
| 14 * result, slices may have one or more subslices. | 15 * result, slices may have one or more subslices. |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 }, | 206 }, |
| 206 | 207 |
| 207 /** | 208 /** |
| 208 * @return {String} User friendly details about this thread. | 209 * @return {String} User friendly details about this thread. |
| 209 */ | 210 */ |
| 210 get userFriendlyDetails() { | 211 get userFriendlyDetails() { |
| 211 return 'pid: ' + this.parent.pid + | 212 return 'pid: ' + this.parent.pid + |
| 212 ', tid: ' + this.tid + | 213 ', tid: ' + this.tid + |
| 213 (this.name ? ', name: ' + this.name : ''); | 214 (this.name ? ', name: ' + this.name : ''); |
| 214 } | 215 } |
| 215 | |
| 216 }; | 216 }; |
| 217 | 217 |
| 218 /** | 218 /** |
| 219 * Comparison between threads that orders first by pid, | 219 * Comparison between threads that orders first by pid, |
| 220 * then by names, then by tid. | 220 * then by names, then by tid. |
| 221 */ | 221 */ |
| 222 TimelineThread.compare = function(x, y) { | 222 TimelineThread.compare = function(x, y) { |
| 223 if (x.parent.pid != y.parent.pid) { | 223 if (x.parent.pid != y.parent.pid) { |
| 224 return TimelineProcess.compare(x.parent, y.parent.pid); | 224 return TimelineProcess.compare(x.parent, y.parent.pid); |
| 225 } | 225 } |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 572 subGroupsByPTID[slicePTID].slices.push(slice); | 572 subGroupsByPTID[slicePTID].slices.push(slice); |
| 573 } | 573 } |
| 574 var groups = []; | 574 var groups = []; |
| 575 for (var ptid in subGroupsByPTID) { | 575 for (var ptid in subGroupsByPTID) { |
| 576 var group = subGroupsByPTID[ptid]; | 576 var group = subGroupsByPTID[ptid]; |
| 577 group.updateBounds(); | 577 group.updateBounds(); |
| 578 groups.push(group); | 578 groups.push(group); |
| 579 } | 579 } |
| 580 return groups; | 580 return groups; |
| 581 } | 581 } |
| 582 | |
| 583 }; | 582 }; |
| 584 | 583 |
| 585 /** | 584 /** |
| 586 * Comparison between counters that orders by pid, then name. | 585 * Comparison between counters that orders by pid, then name. |
| 587 */ | 586 */ |
| 588 TimelineCounter.compare = function(x, y) { | 587 TimelineCounter.compare = function(x, y) { |
| 589 if (x.parent.pid != y.parent.pid) { | 588 if (x.parent.pid != y.parent.pid) { |
| 590 return TimelineProcess.compare(x.parent, y.parent.pid); | 589 return TimelineProcess.compare(x.parent, y.parent.pid); |
| 591 } | 590 } |
| 592 var tmp = x.name.localeCompare(y.name); | 591 var tmp = x.name.localeCompare(y.name); |
| (...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 999 * by 15%. Defaults to true. | 998 * by 15%. Defaults to true. |
| 1000 * @param {Array=} opt_additionalEventData An array of eventData objects | 999 * @param {Array=} opt_additionalEventData An array of eventData objects |
| 1001 * (e.g. array of arrays) to | 1000 * (e.g. array of arrays) to |
| 1002 * import after importing the primary events. | 1001 * import after importing the primary events. |
| 1003 */ | 1002 */ |
| 1004 importEvents: function(eventData, | 1003 importEvents: function(eventData, |
| 1005 opt_zeroAndBoost, opt_additionalEventData) { | 1004 opt_zeroAndBoost, opt_additionalEventData) { |
| 1006 if (opt_zeroAndBoost === undefined) | 1005 if (opt_zeroAndBoost === undefined) |
| 1007 opt_zeroAndBoost = true; | 1006 opt_zeroAndBoost = true; |
| 1008 | 1007 |
| 1009 activeImporters = []; | 1008 var activeImporters = []; |
| 1010 var importer = this.importOneTrace_(eventData, false); | 1009 var importer = this.importOneTrace_(eventData, false); |
| 1011 activeImporters.push(importer); | 1010 activeImporters.push(importer); |
| 1012 if (opt_additionalEventData) { | 1011 if (opt_additionalEventData) { |
| 1013 for (var i = 0; i < opt_additionalEventData.length; ++i) { | 1012 for (var i = 0; i < opt_additionalEventData.length; ++i) { |
| 1014 importer = this.importOneTrace_(opt_additionalEventData[i], true); | 1013 importer = this.importOneTrace_(opt_additionalEventData[i], true); |
| 1015 activeImporters.push(importer); | 1014 activeImporters.push(importer); |
| 1016 } | 1015 } |
| 1017 } | 1016 } |
| 1018 for (var i = 0; i < activeImporters.length; ++i) | 1017 for (var i = 0; i < activeImporters.length; ++i) |
| 1019 activeImporters[i].finalizeImport(); | 1018 activeImporters[i].finalizeImport(); |
| 1020 | 1019 |
| 1021 for (var i = 0; i < activeImporters.length; ++i) | 1020 for (var i = 0; i < activeImporters.length; ++i) |
| 1022 this.pruneEmptyThreads(); | 1021 this.pruneEmptyThreads(); |
| 1023 | 1022 |
| 1024 this.updateBounds(); | 1023 this.updateBounds(); |
| 1025 | 1024 |
| 1026 if (opt_zeroAndBoost) | 1025 if (opt_zeroAndBoost) |
| 1027 this.shiftWorldToZero(); | 1026 this.shiftWorldToZero(); |
| 1028 | 1027 |
| 1029 if (opt_zeroAndBoost && | 1028 if (opt_zeroAndBoost && |
| 1030 this.minTimestamp !== undefined && | 1029 this.minTimestamp !== undefined && |
| 1031 this.maxTimestamp !== undefined) { | 1030 this.maxTimestamp !== undefined) { |
| 1032 var boost = (this.maxTimestamp - this.minTimestamp) * 0.15; | 1031 var boost = (this.maxTimestamp - this.minTimestamp) * 0.15; |
| 1033 this.minTimestamp = this.minTimestamp - boost; | 1032 this.minTimestamp = this.minTimestamp - boost; |
| 1034 this.maxTimestamp = this.maxTimestamp + boost; | 1033 this.maxTimestamp = this.maxTimestamp + boost; |
| 1035 } | 1034 } |
| 1036 } | 1035 } |
| 1037 }; | 1036 }; |
| 1038 | 1037 |
| 1038 /** |
| 1039 * @constructor A filter that can be passed into |
| 1040 * Timeline.findAllObjectsMatchingFilter |
| 1041 */ |
| 1042 function TimelineFilter(text) { |
| 1043 this.text_ = text; |
| 1044 } |
| 1045 TimelineFilter.prototype = { |
| 1046 __proto__: Object.prototype, |
| 1047 |
| 1048 matchSlice: function(slice) { |
| 1049 if (this.text_.length == 0) |
| 1050 return false; |
| 1051 return slice.title.indexOf(this.text_) != -1; |
| 1052 } |
| 1053 |
| 1054 }; |
| 1055 |
| 1039 return { | 1056 return { |
| 1040 getPallette: getPallette, | 1057 getPallette: getPallette, |
| 1041 getPalletteHighlightIdBoost: getPalletteHighlightIdBoost, | 1058 getPalletteHighlightIdBoost: getPalletteHighlightIdBoost, |
| 1042 getColorIdByName: getColorIdByName, | 1059 getColorIdByName: getColorIdByName, |
| 1043 getStringHash: getStringHash, | 1060 getStringHash: getStringHash, |
| 1044 getStringColorId: getStringColorId, | 1061 getStringColorId: getStringColorId, |
| 1045 | 1062 |
| 1046 TimelineSlice: TimelineSlice, | 1063 TimelineSlice: TimelineSlice, |
| 1047 TimelineThreadSlice: TimelineThreadSlice, | 1064 TimelineThreadSlice: TimelineThreadSlice, |
| 1048 TimelineAsyncSlice: TimelineAsyncSlice, | 1065 TimelineAsyncSlice: TimelineAsyncSlice, |
| 1049 TimelineThread: TimelineThread, | 1066 TimelineThread: TimelineThread, |
| 1050 TimelineCounter: TimelineCounter, | 1067 TimelineCounter: TimelineCounter, |
| 1051 TimelineProcess: TimelineProcess, | 1068 TimelineProcess: TimelineProcess, |
| 1052 TimelineCpu: TimelineCpu, | 1069 TimelineCpu: TimelineCpu, |
| 1053 TimelineAsyncSliceGroup: TimelineAsyncSliceGroup, | 1070 TimelineAsyncSliceGroup: TimelineAsyncSliceGroup, |
| 1054 TimelineModel: TimelineModel | 1071 TimelineModel: TimelineModel, |
| 1072 TimelineFilter: TimelineFilter |
| 1055 }; | 1073 }; |
| 1056 | 1074 |
| 1057 }); | 1075 }); |
| OLD | NEW |