diff --git a/app/node_views/results.html b/app/node_views/results.html index 2a31763..db4531f 100644 --- a/app/node_views/results.html +++ b/app/node_views/results.html @@ -5,18 +5,24 @@ - - +

Javascript Spaghetti Profiler

Untangling and counting the spaghettis...
-
Tested url: {{phantomasResults.url}}
+
Tested url:   {{phantomasResults.url}}
+ +
+ New test + + + +

Error: {{phantomasResults.error}}

@@ -27,7 +33,34 @@
Javascript execution tree error
-
+
+

Summary

+
Javascript manipulation time: {{totalJSTime}} ms
+
Javascript onDOMReady time: {{phantomasResults.metrics.domContentLoadedEnd - phantomasResults.metrics.domContentLoaded}} ms
+
Scripts count: {{phantomasResults.metrics.jsCount}}
+
DOM elements count: {{phantomasResults.metrics.DOMelementsCount}}
+
DOM max depth: {{phantomasResults.metrics.DOMelementMaxDepth}}
+
DOM queries: {{phantomasResults.metrics.DOMqueries}}
+
DOM inserts: {{phantomasResults.metrics.DOMinserts}}
+
Events bound: {{phantomasResults.metrics.eventsBound}}
+
document.write() calls: {{phantomasResults.metrics.documentWriteCalls}}
+
eval calls: {{phantomasResults.metrics.evalCalls}}
+
Javascript errors: {{phantomasResults.metrics.jsErrors}}
+
jQuery version: {{phantomasResults.metrics.jQueryVersion}}
+
+ Number of jQuery versions loaded: {{phantomasResults.metrics.jQueryDifferentVersions}} + ({{version}} & ) +
+
+ +
+

Metrics

+
    +
  • {{key}}: {{val}}
  • +
+
+ +

Javascript interactions with the DOM

@@ -143,6 +176,12 @@
- + \ No newline at end of file diff --git a/app/public/scripts/resultsCtrl.js b/app/public/scripts/resultsCtrl.js index 7f8a92e..09b39f3 100644 --- a/app/public/scripts/resultsCtrl.js +++ b/app/public/scripts/resultsCtrl.js @@ -4,11 +4,25 @@ app.controller('ResultsCtrl', function ($scope) { // Grab results from nodeJS served page $scope.phantomasResults = window._phantomas_results; + $scope.view = 'summary'; $scope.slowRequestsOn = false; $scope.slowRequestsLimit = 5; if ($scope.phantomasResults.offenders && $scope.phantomasResults.offenders.javascriptExecutionTree) { $scope.javascript = JSON.parse($scope.phantomasResults.offenders.javascriptExecutionTree); + + // Read the main elements of the tree and sum the total time + $scope.totalJSTime = 0; + treeRunner($scope.javascript, function(node) { + if (node.data.time) { + $scope.totalJSTime += node.data.time; + } + + if (node.data.type !== 'main') { + // Don't check the children + return false; + } + }); } $scope.onNodeDetailsClick = function(node) { @@ -53,4 +67,13 @@ app.controller('ResultsCtrl', function ($scope) { return out; } + // Goes on every node of the tree and calls the function fn. If fn returns false on a node, its children won't be checked. + function treeRunner(node, fn) { + if (fn(node) !== false && node.children) { + node.children.forEach(function(child) { + treeRunner(child, fn); + }); + } + } + }); \ No newline at end of file