-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcoster.js
60 lines (44 loc) · 1.57 KB
/
coster.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
var fs = require('fs');
var data = '' + fs.readFileSync(process.argv[process.argv.length - 1]);
var final = new Set();
data = data.split('\n');
function buildList(prefix, data) {
return data.filter(item => item.indexOf(prefix) != -1).map(item => item.split(prefix)[1]);
}
let list = buildList('DATA:', data);
let chunkNone = [];
let chunkNfa = [];
let chunkCaps = [];
let chunkRefs = [];
function processName(fileSuffix, chunk, data) {
let dataParsed = JSON.parse(data);
let name = dataParsed[0].slice(5);
try {
let nextFileData = fs.readFileSync('./stdouts/' + name + fileSuffix);
let re = /took ([0-9]+.[0-9]+)s/g;
let p;
let totalThisFile = 0;
while ((p = re.exec(nextFileData))) {
chunk.push(Number.parseFloat(p[1]));
if (chunk[chunk.length - 1] > 50) {
console.log('Big Took in ' + name + ' ' + chunk[chunk.length - 1]);
}
totalThisFile++;
}
console.log(name + ' had ' + totalThisFile + ' timings');
} catch (e) {
console.log('FAILDATA: ' + name + ' because ' + e);
}
}
list.forEach(x => processName('_DISABLE_REGULAR_EXPRESSIONS', chunkNone, x));
list.forEach(x => processName('_DISABLE_CAPTURE_GROUPS', chunkNfa, x));
list.forEach(x => processName('_DISABLE_REFINEMENTS', chunkCaps, x));
list.forEach(x => processName('', chunkRefs, x));
function meanChunk(chunk) {
return chunk.reduce((x, y) => x + y, 0) / chunk.length;
}
let means = [meanChunk(chunkNone), meanChunk(chunkNfa), meanChunk(chunkCaps), meanChunk(chunkRefs)];
console.log('Means');
means.forEach(x => console.log(x));
console.log('Rates');
means.forEach(x => console.log(1/x));