Skip to content

Commit e6e48aa

Browse files
committed
benchmark: create simple benchmark
1 parent 010b36a commit e6e48aa

File tree

3 files changed

+15527
-0
lines changed

3 files changed

+15527
-0
lines changed

benchmark/json/json-parser.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
'use strict';
2+
const { readFile } = require('node:fs/promises');
3+
const common = require('../common.js');
4+
const { parse } = require('node:json');
5+
const path = require('node:path');
6+
7+
const configs = {
8+
n: [1024],
9+
};
10+
11+
const bench = common.createBenchmark(main, configs);
12+
13+
async function main(conf) {
14+
bench.start();
15+
16+
const json = await readFile(path.join(__dirname, 'twitter.json'), 'utf-8');
17+
18+
for (let i = 0; i < conf.n; i++) {
19+
parse(json);
20+
}
21+
22+
bench.end(conf.n);
23+
}

benchmark/json/json-v8-parser.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
'use strict';
2+
const { readFile } = require('node:fs/promises');
3+
const common = require('../common.js');
4+
const path = require('node:path');
5+
6+
const configs = {
7+
n: [1024],
8+
};
9+
10+
const bench = common.createBenchmark(main, configs);
11+
12+
async function main(conf) {
13+
bench.start();
14+
15+
const json = await readFile(path.join(__dirname, 'twitter.json'), 'utf-8');
16+
17+
for (let i = 0; i < conf.n; i++) {
18+
JSON.parse(json);
19+
}
20+
21+
bench.end(conf.n);
22+
}

0 commit comments

Comments
 (0)