From c17a4a33e3714a2039c474deb6ee996e7ecd090b Mon Sep 17 00:00:00 2001 From: Peter Hedenskog Date: Tue, 3 Oct 2017 15:22:38 +0200 Subject: [PATCH] Use PageXray 1.0.0 (#1693) --- lib/plugins/assets/aggregator.js | 4 ++-- lib/plugins/assets/assetsBySpeed.js | 18 +++++++++++++----- lib/plugins/html/templates/toplist.pug | 2 +- package.json | 4 ++-- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/lib/plugins/assets/aggregator.js b/lib/plugins/assets/aggregator.js index 7dd4ceb380..27ac09af0d 100644 --- a/lib/plugins/assets/aggregator.js +++ b/lib/plugins/assets/aggregator.js @@ -70,7 +70,7 @@ module.exports = { size: asset.contentSize, page, runPage, - timing: asset.timing, + timings: asset.timings, requestCount: 0 }; urlInfo.requestCount++; @@ -84,7 +84,7 @@ module.exports = { size: asset.contentSize, page, runPage, - timing: asset.timing, + timings: asset.timings, requestCount: 0 }; diff --git a/lib/plugins/assets/assetsBySpeed.js b/lib/plugins/assets/assetsBySpeed.js index 809c2b3244..1edd706d9f 100644 --- a/lib/plugins/assets/assetsBySpeed.js +++ b/lib/plugins/assets/assetsBySpeed.js @@ -8,7 +8,14 @@ class AssetsBySpeed { } add(asset, page, runPage) { - if (asset.timing > this.timing || this.items.length < this.maxSize) { + const totalTime = + asset.timings.blocked + + asset.timings.dns + + asset.timings.connect + + asset.timings.send + + asset.timings.wait + + asset.timings.receive; + if (totalTime > this.totalTime || this.items.length < this.maxSize) { // TODO if this one is slower than an already existing item, replace that! if (!this.items.some(assetInArray => assetInArray.url === asset.url)) { this.items.push({ @@ -17,7 +24,8 @@ class AssetsBySpeed { transferSize: asset.transferSize, lastModification: asset.timeSinceLastModified, cacheTime: asset.expires, - timing: asset.timing, + timings: asset.timings, + totalTime: totalTime, page, runPage }); @@ -25,12 +33,12 @@ class AssetsBySpeed { if (this.items.length > this.maxSize) { this.items.sort(function(asset, asset2) { - return asset2.timing - asset.timing; + return asset2.totalTime - asset.totalTime; }); if (this.items.length > this.maxSize) { this.items.length = this.maxSize; - this.timing = this.items[this.maxSize - 1].timing; + this.totalTime = this.items[this.maxSize - 1].totalTime; } } } @@ -38,7 +46,7 @@ class AssetsBySpeed { getItems() { this.items.sort(function(asset, asset2) { - return asset2.timing - asset.timing; + return asset2.totalTime - asset.totalTime; }); return this.items; diff --git a/lib/plugins/html/templates/toplist.pug b/lib/plugins/html/templates/toplist.pug index 2946fb4589..710a9577db 100644 --- a/lib/plugins/html/templates/toplist.pug +++ b/lib/plugins/html/templates/toplist.pug @@ -12,7 +12,7 @@ mixin rows(assets, showTiming) +durationCell('cache time',asset.cacheTime) +kbSizeCell('size', asset.contentSize) if showTiming - +numberCell('timing', asset.timing.toFixed(0)) + +numberCell('timing', asset.totalTime.toFixed(0)) block content include runInfo diff --git a/package.json b/package.json index 3d85583ce9..81fad57113 100644 --- a/package.json +++ b/package.json @@ -97,14 +97,14 @@ "mkdirp": "0.5.1", "moment": "2.18.1", "node-slack": "0.0.7", - "pagexray": "0.14.3", + "pagexray": "1.0.0", "pug": "2.0.0-rc.2", "s3": "4.4.0", "simplecrawler": "1.1.5", "tape": "4.8.0", "text-table": "0.2.0", "uuid": "^3.0.0", - "webcoach": "0.36.0", + "webcoach": "0.37.0", "webpagetest": "0.3.5", "yargs": "6.6.0" }