-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathutils.js
39 lines (36 loc) · 772 Bytes
/
utils.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
const count = 100000;
const data = require('./data');
const options = {
name: null,
callback: null
};
let i, start;
const done = (error, html) => {
i++;
if (i === count) {
const now = Date.now();
options.callback(null, options.name, now - start);
}
}
exports.test = (name, sample, callback) => {
i = 0;
options.name = name;
options.callback = callback;
sample.prepare(data, () => {
start = Date.now();
for (let j = 0; j < count; j++) {
sample.step(done);
}
});
};
exports.testUnescaped = (name, sample, callback) => {
i = 0;
options.name = name;
options.callback = callback;
sample.prepareUnescaped(data, () => {
start = Date.now();
for (let j = 0; j < count; j++) {
sample.step(done);
}
});
};