-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate-readme.js
More file actions
48 lines (41 loc) · 1.17 KB
/
update-readme.js
File metadata and controls
48 lines (41 loc) · 1.17 KB
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
48
const fs = require('fs');
const runBenchmarks = require('./index.js');
const { results } = runBenchmarks();
function localize (input) {
if (typeof(input) === 'number') {
return input.toLocaleString();
}
return input
}
const tableRows = results.map(function (result) {
let savings = result.gzipSavings + '-' + result.savings;
if (savings.startsWith('N')) {
savings = 'N/A';
}
const rowData = [
result.library + ' ' + result.version,
localize(result.inputBytes),
localize(result.atomizedBytes),
localize(result.inputGzipBytes),
localize(result.atomizedGzipBytes),
savings,
result.timeToAtomizeMs,
result.atomizedErrors
].join(' | ');
return rowData;
});
const readme = [
'# red-perfume-benchmarks',
'',
'Benchmarking Red Perfume against real-world CSS files.',
'',
'',
'* * *',
'',
'',
'Library | Input (bytes) | Atomized (bytes) | Input GZipped (bytes) | Atomized GZipped (bytes) | Savings | Time (ms) | Errors',
':-- | :-- | :-- | :-- | :-- | :-- | :-- | :--',
...tableRows,
''
].join('\n');
fs.writeFileSync('./README.md', readme);