Skip to content

Commit

Permalink
Use PageXray 1.0.0 (#1693)
Browse files Browse the repository at this point in the history
  • Loading branch information
soulgalore authored Oct 3, 2017
1 parent 6425b1e commit c17a4a3
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 deletions.
4 changes: 2 additions & 2 deletions lib/plugins/assets/aggregator.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ module.exports = {
size: asset.contentSize,
page,
runPage,
timing: asset.timing,
timings: asset.timings,
requestCount: 0
};
urlInfo.requestCount++;
Expand All @@ -84,7 +84,7 @@ module.exports = {
size: asset.contentSize,
page,
runPage,
timing: asset.timing,
timings: asset.timings,
requestCount: 0
};

Expand Down
18 changes: 13 additions & 5 deletions lib/plugins/assets/assetsBySpeed.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -17,28 +24,29 @@ class AssetsBySpeed {
transferSize: asset.transferSize,
lastModification: asset.timeSinceLastModified,
cacheTime: asset.expires,
timing: asset.timing,
timings: asset.timings,
totalTime: totalTime,
page,
runPage
});
}

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;
}
}
}
}

getItems() {
this.items.sort(function(asset, asset2) {
return asset2.timing - asset.timing;
return asset2.totalTime - asset.totalTime;
});

return this.items;
Expand Down
2 changes: 1 addition & 1 deletion lib/plugins/html/templates/toplist.pug
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down

0 comments on commit c17a4a3

Please sign in to comment.