-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.js
47 lines (44 loc) · 1.65 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
const graph = require('./src/graph'),
requestPromise = require('./src/request-promise'),
collectPids = require('./src/collect-pids'),
getImagePerformanceAverages = require('./src/image-performance'),
fileSystem = require('./src/file-system'),
argv = require('minimist')(process.argv.slice(2));
(async function() {
const benchMarkFilename = process.env.BENCHMARK_FILENAME;
var performance;
if (argv._.length > 0) {
// If we have input arguments, we don't run tests for any brand by default
performance = {
nap: false,
mrp: false,
ton: false
};
for (let brand of argv._) {
if (performance[brand] === false)
performance[brand] = true;
}
} else {
// No input arguments, so we run the tests for all brands
performance = {
nap: true,
mrp: true,
ton: true
};
}
if (benchMarkFilename) {
performance = fileSystem.loadBenchmarksFromDisk(benchMarkFilename);
} else {
var brandPids = await collectPids(Object.keys(performance).filter(function (brand) {
return performance[brand] && brand
}));
performance = {
nap: performance.nap && await getImagePerformanceAverages('net-a-porter', brandPids.nap.pids),
mrp: performance.mrp && await getImagePerformanceAverages('mrporter', brandPids.mrp.pids),
ton: performance.ton && await getImagePerformanceAverages('theoutnet', brandPids.ton.pids)
}
fileSystem.saveBenchmarksToDisk(performance);
}
;
graph(performance);
})();