Improve Phantomas metrics reporting

This commit is contained in:
Gaël Métais
2014-08-25 17:31:07 +02:00
parent fce76be041
commit 96e5eb72df
2 changed files with 45 additions and 0 deletions
+17
View File
@@ -3,12 +3,15 @@ var app = angular.module('Results', []);
app.controller('ResultsCtrl', function ($scope) {
// Grab results from nodeJS served page
$scope.phantomasResults = window._phantomas_results;
$scope.phantomasMetadata = window._phantomas_metadata.metrics;
$scope.view = 'summary';
$scope.slowRequestsOn = false;
$scope.slowRequestsLimit = 5;
if ($scope.phantomasResults.offenders && $scope.phantomasResults.offenders.javascriptExecutionTree) {
// Get the execution tree from the offenders
$scope.javascript = JSON.parse($scope.phantomasResults.offenders.javascriptExecutionTree);
// Read the main elements of the tree and sum the total time
@@ -25,6 +28,20 @@ app.controller('ResultsCtrl', function ($scope) {
});
}
if ($scope.phantomasResults.metrics && $scope.phantomasResults.offenders) {
// Get the Phantomas modules from metadata
$scope.metricsModule = {};
for (var metricName in $scope.phantomasMetadata) {
var metric = $scope.phantomasMetadata[metricName];
if (!$scope.metricsModule[metric.module]) {
$scope.metricsModule[metric.module] = {};
}
$scope.metricsModule[metric.module][metricName] = metric;
}
}
$scope.setView = function(viewName) {
$scope.view = viewName;
};