OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 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 1437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1448 this.id; | 1448 this.id; |
1449 /** @type {!WebInspector.TracingModel.Event} */ | 1449 /** @type {!WebInspector.TracingModel.Event} */ |
1450 this.event; | 1450 this.event; |
1451 /** @type {?Map<string,!WebInspector.TimelineModel.ProfileTreeNode>} */ | 1451 /** @type {?Map<string,!WebInspector.TimelineModel.ProfileTreeNode>} */ |
1452 this.children; | 1452 this.children; |
1453 /** @type {?WebInspector.TimelineModel.ProfileTreeNode} */ | 1453 /** @type {?WebInspector.TimelineModel.ProfileTreeNode} */ |
1454 this.parent; | 1454 this.parent; |
1455 } | 1455 } |
1456 | 1456 |
1457 /** | 1457 /** |
| 1458 * @param {!Array<!WebInspector.TracingModel.Event>} events |
| 1459 * @param {number} startTime |
| 1460 * @param {number} endTime |
| 1461 * @param {!Array<!WebInspector.TraceEventFilter>} filters |
| 1462 * @param {function(!WebInspector.TracingModel.Event):string} eventIdCallback |
| 1463 * @return {!WebInspector.TimelineModel.ProfileTreeNode} |
| 1464 */ |
| 1465 WebInspector.TimelineModel.buildTopDownTree = function(events, startTime, endTim
e, filters, eventIdCallback) |
| 1466 { |
| 1467 // Temporarily deposit a big enough value that exceeds the max recording tim
e. |
| 1468 var /** @const */ initialTime = 1e7; |
| 1469 var root = new WebInspector.TimelineModel.ProfileTreeNode(); |
| 1470 root.totalTime = initialTime; |
| 1471 root.selfTime = initialTime; |
| 1472 root.name = WebInspector.UIString("Top-Down Chart"); |
| 1473 var parent = root; |
| 1474 |
| 1475 /** |
| 1476 * @param {!WebInspector.TracingModel.Event} e |
| 1477 * @return {boolean} |
| 1478 */ |
| 1479 function filter(e) |
| 1480 { |
| 1481 if (!e.endTime && e.phase !== WebInspector.TracingModel.Phase.Instant) |
| 1482 return false; |
| 1483 if (e.endTime <= startTime || e.startTime >= endTime) |
| 1484 return false; |
| 1485 if (WebInspector.TracingModel.isAsyncPhase(e.phase)) |
| 1486 return false; |
| 1487 for (var filter of filters) { |
| 1488 if (!filter.accept(e)) |
| 1489 return false; |
| 1490 } |
| 1491 return true; |
| 1492 } |
| 1493 |
| 1494 /** |
| 1495 * @param {!WebInspector.TracingModel.Event} e |
| 1496 */ |
| 1497 function onStartEvent(e) |
| 1498 { |
| 1499 if (!filter(e)) |
| 1500 return; |
| 1501 var time = Math.min(endTime, e.endTime) - Math.max(startTime, e.startTim
e); |
| 1502 var id = eventIdCallback(e); |
| 1503 if (!parent.children) |
| 1504 parent.children = /** @type {!Map<string,!WebInspector.TimelineModel
.ProfileTreeNode>} */ (new Map()); |
| 1505 var node = parent.children.get(id); |
| 1506 if (node) { |
| 1507 node.selfTime += time; |
| 1508 node.totalTime += time; |
| 1509 } else { |
| 1510 node = new WebInspector.TimelineModel.ProfileTreeNode(); |
| 1511 node.totalTime = time; |
| 1512 node.selfTime = time; |
| 1513 node.parent = parent; |
| 1514 node.name = eventName(e); |
| 1515 node.id = id; |
| 1516 node.event = e; |
| 1517 parent.children.set(id, node); |
| 1518 } |
| 1519 parent.selfTime -= time; |
| 1520 if (parent.selfTime < 0) { |
| 1521 console.log("Error: Negative self of " + parent.selfTime, e); |
| 1522 parent.selfTime = 0; |
| 1523 } |
| 1524 parent = node; |
| 1525 } |
| 1526 |
| 1527 /** |
| 1528 * @param {!WebInspector.TracingModel.Event} e |
| 1529 */ |
| 1530 function onEndEvent(e) |
| 1531 { |
| 1532 if (!filter(e)) |
| 1533 return; |
| 1534 parent = parent.parent; |
| 1535 } |
| 1536 |
| 1537 /** |
| 1538 * @param {!WebInspector.TracingModel.Event} e |
| 1539 * @return {string} |
| 1540 */ |
| 1541 function eventName(e) |
| 1542 { |
| 1543 if (e.name === "JSFrame") |
| 1544 return WebInspector.beautifyFunctionName(e.args.data.functionName); |
| 1545 if (e.name === "EventDispatch") |
| 1546 return WebInspector.UIString("Event%s", e.args.data ? " (" + e.args.
data.type + ")" : ""); |
| 1547 return e.name; |
| 1548 } |
| 1549 |
| 1550 WebInspector.TimelineModel.forEachEvent(events, onStartEvent, onEndEvent); |
| 1551 root.totalTime -= root.selfTime; |
| 1552 root.selfTime = 0; |
| 1553 return root; |
| 1554 } |
| 1555 |
| 1556 /** |
| 1557 * @param {!WebInspector.TimelineModel.ProfileTreeNode} topDownTree |
| 1558 * @param {function(!WebInspector.TimelineModel.ProfileTreeNode):?WebInspector.T
imelineModel.ProfileTreeNode=} groupingCallback |
| 1559 * @return {!WebInspector.TimelineModel.ProfileTreeNode} |
| 1560 */ |
| 1561 WebInspector.TimelineModel.buildBottomUpTree = function(topDownTree, groupingCal
lback) |
| 1562 { |
| 1563 var buRoot = new WebInspector.TimelineModel.ProfileTreeNode(); |
| 1564 buRoot.totalTime = 0; |
| 1565 buRoot.name = WebInspector.UIString("Bottom-Up Chart"); |
| 1566 /** @type {!Map<string,!WebInspector.TimelineModel.ProfileTreeNode>} */ |
| 1567 buRoot.children = new Map(); |
| 1568 processNode(topDownTree); |
| 1569 |
| 1570 /** |
| 1571 * @param {!WebInspector.TimelineModel.ProfileTreeNode} tdNode |
| 1572 */ |
| 1573 function processNode(tdNode) |
| 1574 { |
| 1575 if (tdNode.selfTime > 0) { |
| 1576 var buParent = groupingCallback && groupingCallback(tdNode) || buRoo
t; |
| 1577 appendNode(tdNode, buParent); |
| 1578 } |
| 1579 if (tdNode.children) |
| 1580 tdNode.children.forEach(processNode); |
| 1581 } |
| 1582 |
| 1583 /** |
| 1584 * @param {!WebInspector.TimelineModel.ProfileTreeNode} tdNode |
| 1585 * @param {!WebInspector.TimelineModel.ProfileTreeNode} buParent |
| 1586 */ |
| 1587 function appendNode(tdNode, buParent) |
| 1588 { |
| 1589 var time = tdNode.selfTime; |
| 1590 buParent.totalTime += time; |
| 1591 while (tdNode.parent) { |
| 1592 if (!buParent.children) |
| 1593 buParent.children = /** @type {!Map<string,!WebInspector.Timelin
eModel.ProfileTreeNode>} */ (new Map()); |
| 1594 var id = tdNode.id; |
| 1595 var buNode = buParent.children.get(id); |
| 1596 if (!buNode) { |
| 1597 buNode = new WebInspector.TimelineModel.ProfileTreeNode(); |
| 1598 buNode.totalTime = time; |
| 1599 buNode.name = tdNode.name; |
| 1600 buNode.event = tdNode.event; |
| 1601 buNode.id = id; |
| 1602 buParent.children.set(id, buNode); |
| 1603 } else { |
| 1604 buNode.totalTime += time; |
| 1605 } |
| 1606 tdNode = tdNode.parent; |
| 1607 buParent = buNode; |
| 1608 } |
| 1609 } |
| 1610 |
| 1611 return buRoot; |
| 1612 } |
| 1613 |
| 1614 /** |
1458 * @constructor | 1615 * @constructor |
1459 * @param {!WebInspector.TracingModel.Event} event | 1616 * @param {!WebInspector.TracingModel.Event} event |
1460 */ | 1617 */ |
1461 WebInspector.TimelineModel.NetworkRequest = function(event) | 1618 WebInspector.TimelineModel.NetworkRequest = function(event) |
1462 { | 1619 { |
1463 this.startTime = event.name === WebInspector.TimelineModel.RecordType.Resour
ceSendRequest ? event.startTime : 0; | 1620 this.startTime = event.name === WebInspector.TimelineModel.RecordType.Resour
ceSendRequest ? event.startTime : 0; |
1464 this.endTime = Infinity; | 1621 this.endTime = Infinity; |
1465 this.addEvent(event); | 1622 this.addEvent(event); |
1466 } | 1623 } |
1467 | 1624 |
(...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2178 /** @type {!Object.<string, !Array.<!WebInspector.InvalidationTrackingEv
ent>>} */ | 2335 /** @type {!Object.<string, !Array.<!WebInspector.InvalidationTrackingEv
ent>>} */ |
2179 this._invalidations = {}; | 2336 this._invalidations = {}; |
2180 /** @type {!Object.<number, !Array.<!WebInspector.InvalidationTrackingEv
ent>>} */ | 2337 /** @type {!Object.<number, !Array.<!WebInspector.InvalidationTrackingEv
ent>>} */ |
2181 this._invalidationsByNodeId = {}; | 2338 this._invalidationsByNodeId = {}; |
2182 | 2339 |
2183 this._lastRecalcStyle = undefined; | 2340 this._lastRecalcStyle = undefined; |
2184 this._lastPaintWithLayer = undefined; | 2341 this._lastPaintWithLayer = undefined; |
2185 this._didPaint = false; | 2342 this._didPaint = false; |
2186 } | 2343 } |
2187 } | 2344 } |
OLD | NEW |