OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple 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 | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 1113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1124 | 1124 |
1125 var index = 0; | 1125 var index = 0; |
1126 | 1126 |
1127 var openIntervals = []; | 1127 var openIntervals = []; |
1128 var stackTrace = []; | 1128 var stackTrace = []; |
1129 var maxDepth = 5; // minimum stack depth for the case when we see no act
ivity. | 1129 var maxDepth = 5; // minimum stack depth for the case when we see no act
ivity. |
1130 var depth = 0; | 1130 var depth = 0; |
1131 | 1131 |
1132 /** | 1132 /** |
1133 * @constructor | 1133 * @constructor |
1134 * @param {string} color | |
1135 * @param {number} depth | 1134 * @param {number} depth |
1136 * @param {number} duration | 1135 * @param {number} duration |
1137 * @param {number} startTime | 1136 * @param {number} startTime |
1138 * @param {!Object} node | 1137 * @param {!Object} node |
1139 */ | 1138 */ |
1140 function ChartEntry(color, depth, duration, startTime, node) | 1139 function ChartEntry(depth, duration, startTime, node) |
1141 { | 1140 { |
1142 this.color = color; | |
1143 this.depth = depth; | 1141 this.depth = depth; |
1144 this.duration = duration; | 1142 this.duration = duration; |
1145 this.startTime = startTime; | 1143 this.startTime = startTime; |
1146 this.node = node; | 1144 this.node = node; |
1147 this.selfTime = 0; | 1145 this.selfTime = 0; |
1148 } | 1146 } |
1149 var entries = /** @type {!Array.<!ChartEntry>} */ ([]); | 1147 var entries = /** @type {!Array.<!ChartEntry>} */ ([]); |
1150 | 1148 |
1151 for (var sampleIndex = 0; sampleIndex < samplesCount; sampleIndex++) { | 1149 for (var sampleIndex = 0; sampleIndex < samplesCount; sampleIndex++) { |
1152 var node = idToNode[samples[sampleIndex]]; | 1150 var node = idToNode[samples[sampleIndex]]; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1185 if (depth < openIntervals.length) | 1183 if (depth < openIntervals.length) |
1186 openIntervals.length = depth; | 1184 openIntervals.length = depth; |
1187 if (!node) { | 1185 if (!node) { |
1188 entries[intervalIndex].selfTime += samplingInterval; | 1186 entries[intervalIndex].selfTime += samplingInterval; |
1189 continue; | 1187 continue; |
1190 } | 1188 } |
1191 | 1189 |
1192 var colorGenerator = this._colorGenerator; | 1190 var colorGenerator = this._colorGenerator; |
1193 var color = ""; | 1191 var color = ""; |
1194 while (node) { | 1192 while (node) { |
1195 color = colorGenerator.colorForID(node.functionName + ":" + node
.url + ":" + node.lineNumber); | 1193 entries.push(new ChartEntry(depth, samplingInterval, sampleIndex
* samplingInterval, node)); |
1196 entries.push(new ChartEntry(color, depth, samplingInterval, samp
leIndex * samplingInterval, node)); | |
1197 openIntervals.push({node: node, index: index}); | 1194 openIntervals.push({node: node, index: index}); |
1198 ++index; | 1195 ++index; |
1199 | 1196 |
1200 node = stackTrace.pop(); | 1197 node = stackTrace.pop(); |
1201 ++depth; | 1198 ++depth; |
1202 } | 1199 } |
1203 entries[entries.length - 1].selfTime += samplingInterval; | 1200 entries[entries.length - 1].selfTime += samplingInterval; |
1204 } | 1201 } |
1205 | 1202 |
1206 var entryColors = new Array(entries.length); | |
1207 var entryNodes = new Array(entries.length); | 1203 var entryNodes = new Array(entries.length); |
1208 var entryLevels = new Uint8Array(entries.length); | 1204 var entryLevels = new Uint8Array(entries.length); |
1209 var entryTotalTimes = new Float32Array(entries.length); | 1205 var entryTotalTimes = new Float32Array(entries.length); |
1210 var entrySelfTimes = new Float32Array(entries.length); | 1206 var entrySelfTimes = new Float32Array(entries.length); |
1211 var entryOffsets = new Float32Array(entries.length); | 1207 var entryOffsets = new Float32Array(entries.length); |
1212 var entryTitles = new Array(entries.length); | |
1213 var entryDeoptFlags = new Uint8Array(entries.length); | |
1214 | 1208 |
1215 for (var i = 0; i < entries.length; ++i) { | 1209 for (var i = 0; i < entries.length; ++i) { |
1216 var entry = entries[i]; | 1210 var entry = entries[i]; |
1217 entryNodes[i] = entry.node; | 1211 entryNodes[i] = entry.node; |
1218 entryColors[i] = entry.color; | |
1219 entryLevels[i] = entry.depth; | 1212 entryLevels[i] = entry.depth; |
1220 entryTotalTimes[i] = entry.duration; | 1213 entryTotalTimes[i] = entry.duration; |
1221 entryOffsets[i] = entry.startTime; | 1214 entryOffsets[i] = entry.startTime; |
1222 entryTitles[i] = entry.node.functionName; | 1215 entrySelfTimes[i] = entry.selfTime; |
1223 var reason = entry.node.deoptReason; | |
1224 entryDeoptFlags[i] = (reason && reason !== "no reason"); | |
1225 } | 1216 } |
1226 | 1217 |
1227 this._maxStackDepth = Math.max(maxDepth, depth); | 1218 this._maxStackDepth = Math.max(maxDepth, depth); |
1228 | 1219 |
1229 this._timelineData = { | 1220 this._timelineData = { |
1230 entryLevels: entryLevels, | 1221 entryLevels: entryLevels, |
1231 entryTotalTimes: entryTotalTimes, | 1222 entryTotalTimes: entryTotalTimes, |
1232 entryOffsets: entryOffsets, | 1223 entryOffsets: entryOffsets, |
1233 }; | 1224 }; |
1234 | 1225 |
1235 this._entryTitles = entryTitles; | |
1236 this._entryNodes = entryNodes; | 1226 this._entryNodes = entryNodes; |
1237 this._entrySelfTimes = entrySelfTimes; | 1227 this._entrySelfTimes = entrySelfTimes; |
1238 this._entryDeoptFlags = entryDeoptFlags; | |
1239 this._entryColors = entryColors; | |
1240 | 1228 |
1241 return /** @type {!WebInspector.FlameChart.TimelineData} */ (this._timel
ineData); | 1229 return /** @type {!WebInspector.FlameChart.TimelineData} */ (this._timel
ineData); |
1242 }, | 1230 }, |
1243 | 1231 |
1244 /** | 1232 /** |
1245 * @param {number} ms | 1233 * @param {number} ms |
1246 * @return {string} | 1234 * @return {string} |
1247 */ | 1235 */ |
1248 _millisecondsToString: function(ms) | 1236 _millisecondsToString: function(ms) |
1249 { | 1237 { |
(...skipping 17 matching lines...) Expand all Loading... |
1267 | 1255 |
1268 var entryInfo = []; | 1256 var entryInfo = []; |
1269 function pushEntryInfoRow(title, text) | 1257 function pushEntryInfoRow(title, text) |
1270 { | 1258 { |
1271 var row = {}; | 1259 var row = {}; |
1272 row.title = title; | 1260 row.title = title; |
1273 row.text = text; | 1261 row.text = text; |
1274 entryInfo.push(row); | 1262 entryInfo.push(row); |
1275 } | 1263 } |
1276 | 1264 |
1277 pushEntryInfoRow(WebInspector.UIString("Name"), this._entryTitles[entryI
ndex]); | 1265 pushEntryInfoRow(WebInspector.UIString("Name"), node.functionName); |
1278 var selfTime = this._millisecondsToString(this._entrySelfTimes[entryInde
x]); | 1266 var selfTime = this._millisecondsToString(this._entrySelfTimes[entryInde
x]); |
1279 var totalTime = this._millisecondsToString(timelineData.entryTotalTimes[
entryIndex]); | 1267 var totalTime = this._millisecondsToString(timelineData.entryTotalTimes[
entryIndex]); |
1280 pushEntryInfoRow(WebInspector.UIString("Self time"), selfTime); | 1268 pushEntryInfoRow(WebInspector.UIString("Self time"), selfTime); |
1281 pushEntryInfoRow(WebInspector.UIString("Total time"), totalTime); | 1269 pushEntryInfoRow(WebInspector.UIString("Total time"), totalTime); |
1282 if (node.url) | 1270 if (node.url) |
1283 pushEntryInfoRow(WebInspector.UIString("URL"), node.url + ":" + node
.lineNumber); | 1271 pushEntryInfoRow(WebInspector.UIString("URL"), node.url + ":" + node
.lineNumber); |
1284 pushEntryInfoRow(WebInspector.UIString("Aggregated self time"), Number.s
econdsToString(node.selfTime / 1000, true)); | 1272 pushEntryInfoRow(WebInspector.UIString("Aggregated self time"), Number.s
econdsToString(node.selfTime / 1000, true)); |
1285 pushEntryInfoRow(WebInspector.UIString("Aggregated total time"), Number.
secondsToString(node.totalTime / 1000, true)); | 1273 pushEntryInfoRow(WebInspector.UIString("Aggregated total time"), Number.
secondsToString(node.totalTime / 1000, true)); |
1286 if (node.deoptReason && node.deoptReason !== "no reason") | 1274 if (node.deoptReason && node.deoptReason !== "no reason") |
1287 pushEntryInfoRow(WebInspector.UIString("Not optimized"), node.deoptR
eason); | 1275 pushEntryInfoRow(WebInspector.UIString("Not optimized"), node.deoptR
eason); |
1288 | 1276 |
1289 return entryInfo; | 1277 return entryInfo; |
1290 }, | 1278 }, |
1291 | 1279 |
1292 /** | 1280 /** |
1293 * @param {number} entryIndex | 1281 * @param {number} entryIndex |
1294 * @return {boolean} | 1282 * @return {boolean} |
1295 */ | 1283 */ |
1296 canJumpToEntry: function(entryIndex) | 1284 canJumpToEntry: function(entryIndex) |
1297 { | 1285 { |
1298 return this._entryNodes[entryIndex].scriptId !== "0"; | 1286 return this._entryNodes[entryIndex].scriptId !== "0"; |
1299 }, | 1287 }, |
1300 | 1288 |
1301 /** | 1289 /** |
1302 * @param {number} entryIndex | 1290 * @param {number} entryIndex |
1303 * @return {?string} | 1291 * @return {?string} |
1304 */ | 1292 */ |
1305 entryTitle: function(entryIndex) | 1293 entryTitle: function(entryIndex) |
1306 { | 1294 { |
1307 return this._entryTitles[entryIndex]; | 1295 var node = this._entryNodes[entryIndex]; |
| 1296 return node.functionName; |
1308 }, | 1297 }, |
1309 | 1298 |
1310 /** | 1299 /** |
1311 * @param {number} entryIndex | 1300 * @param {number} entryIndex |
1312 * @return {?string} | 1301 * @return {?string} |
1313 */ | 1302 */ |
1314 entryFont: function(entryIndex) | 1303 entryFont: function(entryIndex) |
1315 { | 1304 { |
1316 if (!this._font) { | 1305 if (!this._font) { |
1317 this._font = (this.barHeight() - 4) + "px " + WebInspector.fontFamil
y(); | 1306 this._font = (this.barHeight() - 4) + "px " + WebInspector.fontFamil
y(); |
1318 this._boldFont = "bold " + this._font; | 1307 this._boldFont = "bold " + this._font; |
1319 } | 1308 } |
1320 return this._entryDeoptFlags[entryIndex] ? this._boldFont : this._font; | 1309 var node = this._entryNodes[entryIndex]; |
| 1310 var reason = node.deoptReason; |
| 1311 return (reason && reason !== "no reason") ? this._boldFont : this._font; |
1321 }, | 1312 }, |
1322 | 1313 |
1323 /** | 1314 /** |
1324 * @param {number} entryIndex | 1315 * @param {number} entryIndex |
1325 * @return {!Object} | 1316 * @return {!Object} |
1326 */ | 1317 */ |
1327 entryData: function(entryIndex) | 1318 entryData: function(entryIndex) |
1328 { | 1319 { |
1329 return this._entryNodes[entryIndex]; | 1320 return this._entryNodes[entryIndex]; |
1330 }, | 1321 }, |
1331 | 1322 |
1332 /** | 1323 /** |
1333 * @param {number} entryIndex | 1324 * @param {number} entryIndex |
1334 * @return {!string} | 1325 * @return {!string} |
1335 */ | 1326 */ |
1336 entryColor: function(entryIndex) | 1327 entryColor: function(entryIndex) |
1337 { | 1328 { |
1338 return this._entryColors[entryIndex]; | 1329 var node = this._entryNodes[entryIndex]; |
| 1330 return this._colorGenerator.colorForID(node.functionName + ":" + node.ur
l + ":" + node.lineNumber);; |
1339 }, | 1331 }, |
1340 } | 1332 } |
OLD | NEW |