-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f74a7e9
commit aaf213b
Showing
7 changed files
with
1,333 additions
and
691 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
'use strict'; | ||
|
||
const statsHelpers = require('../../lib/support/statsHelpers'); | ||
const METRIC_NAMES = [ | ||
'critical-request-chains', | ||
'first-meaningful-paint', | ||
'speed-index-metric', | ||
'estimated-input-latency', | ||
'first-interactive', | ||
'consistently-interactive' | ||
]; | ||
|
||
function replaceAll(str, search, replacement) { | ||
return str.replace(new RegExp(search, 'g'), replacement); | ||
} | ||
|
||
module.exports = { | ||
stats: {}, | ||
groups: {}, | ||
addToAggregate(data, group) { | ||
if (this.groups[group] === undefined) { | ||
this.groups[group] = {}; | ||
} | ||
let stats = this.stats; | ||
let groups = this.groups; | ||
|
||
METRIC_NAMES.forEach(function(metric) { | ||
if (metric == 'critical-request-chains') { | ||
statsHelpers.pushGroupStats( | ||
stats, | ||
groups[group], | ||
metric, | ||
parseInt(data[metric].displayValue) | ||
); | ||
} else { | ||
statsHelpers.pushGroupStats( | ||
stats, | ||
groups[group], | ||
metric, | ||
parseInt(data[metric].rawValue) | ||
); | ||
} | ||
}); | ||
}, | ||
summarize() { | ||
if ( | ||
Object.keys(this.stats).length === 0 || | ||
Object.keys(this.groups).length === 0 | ||
) | ||
return undefined; | ||
|
||
const summary = { | ||
groups: {} | ||
}; | ||
const tmp = {}; | ||
for (let group of Object.keys(this.groups)) { | ||
for (let stat of Object.keys(this.stats)) { | ||
statsHelpers.setStatsSummary( | ||
tmp, | ||
replaceAll(stat, '-', ''), | ||
this.stats[stat] | ||
); | ||
} | ||
summary.groups[group] = tmp; | ||
} | ||
|
||
return summary; | ||
} | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.