Skip to content

Commit 665c4dd

Browse files
committed
chore: add benchmark suite using @twada/benchmark-commits
1 parent 1958013 commit 665c4dd

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

bench.mjs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { runBenchmark } from '@twada/benchmark-commits';
2+
import { parse } from 'acorn';
3+
import { readFileSync } from 'node:fs';
4+
import { join, dirname } from 'node:path';
5+
import { fileURLToPath, pathToFileURL } from 'node:url';
6+
import assert from 'node:assert/strict';
7+
const __dirname = dirname(fileURLToPath(import.meta.url));
8+
const targetCode = readFileSync(join(__dirname, 'node_modules', 'rimraf', 'rimraf.js'));
9+
10+
const commits = [
11+
'v1.6.0',
12+
'master'
13+
];
14+
15+
runBenchmark(commits, async ({ suite, spec, dir }) => {
16+
let unassertAst;
17+
if (spec.git === 'v1.6.0') {
18+
unassertAst = (await import(pathToFileURL(`${dir}/index.js`))).default;
19+
} else if (spec.git === 'master') {
20+
unassertAst = (await import(pathToFileURL(`${dir}/src/index.mjs`))).unassertAst;
21+
} else {
22+
assert.fail('cannot be here');
23+
}
24+
return () => {
25+
const ast = parse(targetCode, { ecmaVersion: '2022' });
26+
const modifiedAst = unassertAst(ast);
27+
assert(modifiedAst);
28+
};
29+
}).then((suite) => {
30+
console.log('FINISHED');
31+
});

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy