-
Notifications
You must be signed in to change notification settings - Fork 44
/
results2table.js
82 lines (77 loc) · 3.02 KB
/
results2table.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
'use strict'
const approx = require('approximate-number')
const fs = require('fs')
const results = JSON.parse(fs.readFileSync('./benchmark-results.json'))
const size = {
'overall': 1124628
}
const testName = {
'overall': 'Overall',
'0A-spec-01-example-v0.4.0': 'Spec Example: v0.4.0',
'0A-spec-02-example-hard-unicode': 'Spec Example: Hard Unicode',
'0B-types-array-inline-empty': 'Types: Array, Inline',
'0B-types-array': 'Types: Array',
'0B-types-scalar-bools': 'Types: Boolean,',
'0B-types-scalar-datetimes': 'Types: Datetime',
'0B-types-scalar-floats': 'Types: Float',
'0B-types-scalar-ints': 'Types: Int',
'0B-types-scalar-literal-7-char': 'Types: Literal String, 7 char',
'0B-types-scalar-literal-92-char': 'Types: Literal String, 92 char',
'0B-types-scalar-literal-multiline-1079-chars': 'Types: Literal String, Multiline, 1079 char',
'0B-types-scalar-string-7-char': 'Types: Basic String, 7 char',
'0B-types-scalar-string-92-char': 'Types: Basic String, 92 char',
'0B-types-scalar-string-multiline-1079-chars': 'Types: Basic String, 1079 char',
'0B-types-table-inline-empty': 'Types: Table, Inline',
'0B-types-table': 'Types: Table',
'0C-scaling-array-inline-1000': 'Scaling: Array, Inline, 1000 elements',
'0C-scaling-array-inline-nested-1000': 'Scaling: Array, Nested, 1000 deep',
'0C-scaling-literal-40kb': 'Scaling: Literal String, 40kb',
'0C-scaling-scalar-literal-multiline-40kb': 'Scaling: Literal String, Multiline, 40kb',
'0C-scaling-scalar-string-multiline-40kb': 'Scaling: Basic String, Multiline, 40kb',
'0C-scaling-string-40kb': 'Scaling: Basic String, 40kb',
'0C-scaling-table-inline-1000': 'Scaling: Table, Inline, 1000 elements',
'0C-scaling-table-inline-nested-1000': 'Scaling: Table, Inline, Nested, 1000 deep'
}
function fileSize (name) {
/* eslint-disable security/detect-non-literal-fs-filename */
try {
return fs.readFileSync('benchmark/' + name + '.toml').length
} catch (_) {
return fs.readFileSync('test/spec-test/' + name + '.toml').length
}
}
function repeat (str, count) {
let result = ''
for (let ii = 0; ii < count; ++ii) result += str
return result
}
for (let nodev in results) {
console.log(`### ${nodev}`)
const tests = Object.keys(results[nodev])
const libs = Object.keys(results[nodev][tests[0]])
console.log('')
console.log('| |' + libs.map(_ => ` ${_.replace(/[/]/, '/<wbr>')} |`).join(''))
console.log('| - |' + libs.map(_ => ` :${repeat('-', _.length - 2)}: |`).join(''))
for (let name of tests) {
if (!size[name]) {
try {
size[name] = fileSize(name)
} catch (_) {
continue
}
}
const bench = results[nodev][name]
let line = `| **${testName[name] || name}** |`
for (let lib of libs) {
if (!bench[lib] || bench[lib].crashed) {
line += ` - |`
} else {
const speed = bench[lib].opsec * size[name]
const mb = speed / 1000000
line += ` ${approx(mb)}MB/sec<br><small>${bench[lib].errmargin}%</small> |`
}
}
console.log(line)
}
console.log('')
}