From 6f0b97e760402dec7de2061573a2de0053c189fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20M=C3=A9tais?= Date: Tue, 22 Dec 2015 19:19:39 +0100 Subject: [PATCH] Removed some unused data from jsExecution in JSON --- .../custom_modules/core/scopeYLT/scopeYLT.js | 58 +++++++++++++++++-- 1 file changed, 52 insertions(+), 6 deletions(-) diff --git a/lib/tools/phantomas/custom_modules/core/scopeYLT/scopeYLT.js b/lib/tools/phantomas/custom_modules/core/scopeYLT/scopeYLT.js index 59e21a3..5bd04d3 100644 --- a/lib/tools/phantomas/custom_modules/core/scopeYLT/scopeYLT.js +++ b/lib/tools/phantomas/custom_modules/core/scopeYLT/scopeYLT.js @@ -110,29 +110,75 @@ exports.module = function(phantomas) { phantomas.log('Entering deep Javascript analysis mode'); } - // Add a child but don't enter his context + // Add a child but don't enter its context function pushContext(data) { - if (depth === 0 || deepAnalysis) { + + // Some data is not needed on subchildren + if (depth === 0) { data.timestamp = Date.now() - responseEndTime; data.loadingStep = phantomas.currentStep || ''; + } + + // Some data is not needed on subchildren + if (depth > 0) { + if (data.backtrace) { + delete data.backtrace; + } + if (data.resultsNumber) { + delete data.resultsNumber; + } + } + + if (depth === 0 || deepAnalysis) { currentContext.addChild(data); } } - // Add a child to the current context and enter his context + // Add a child to the current context and enter its context function enterContext(data) { - if (depth === 0 || deepAnalysis) { + + // Some data is not needed on subchildren + if (depth === 0) { data.timestamp = Date.now() - responseEndTime; data.loadingStep = phantomas.currentStep || ''; + } + + // Some data is not needed on subchildren + if (depth > 0) { + if (data.backtrace) { + delete data.backtrace; + } + if (data.resultsNumber) { + delete data.resultsNumber; + } + } + + if (depth === 0 || deepAnalysis) { currentContext = currentContext.addChild(data); } + depth ++; } // Save given data in the current context and jump change current context to its parent function leaveContext(moreData) { - if (depth === 1 || deepAnalysis) { + + // Some data is not needed on subchildren + if (depth === 1) { currentContext.data.time = Date.now() - currentContext.data.timestamp - responseEndTime; + } + + // Some data is not needed on subchildren + if (depth > 1) { + if (moreData && moreData.backtrace) { + delete moreData.backtrace; + } + if (moreData && moreData.resultsNumber) { + delete moreData.resultsNumber; + } + } + + if (depth === 1 || deepAnalysis) { // Merge previous data with moreData (ovewrites if exists) if (moreData) { @@ -148,6 +194,7 @@ exports.module = function(phantomas) { currentContext = parent; } } + depth --; } @@ -161,7 +208,6 @@ exports.module = function(phantomas) { if (root !== currentContext) { return null; } - var current = currentContext; function recusiveRead(node) { if (node.children.length === 0) {