-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathperf-quickjs.js
More file actions
45 lines (36 loc) · 1.1 KB
/
perf-quickjs.js
File metadata and controls
45 lines (36 loc) · 1.1 KB
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
import * as path from 'node:path';
import { build } from 'esbuild';
import { $ } from 'zx';
let baseDir = import.meta.dirname;
let libs = [
['unicode-segmenter/grapheme', 'bundle-entries/unicode-segmenter.js', 'perf-quickjs/unicode-segmenter.js'],
['graphemer', 'bundle-entries/graphemer.js', 'perf-quickjs/graphemer.js'],
['grapheme-splitter', 'bundle-entries/grapheme-splitter.js', 'perf-quickjs/grapheme-splitter.js'],
];
let benches = [];
for (let lib of libs) {
let libName = lib[0];
let libEntry = path.join(baseDir, lib[1]);
let execEntry = path.join(baseDir, lib[2]);
let bundleEntry = libEntry.replace(/\.js$/, '.bundle.js');
await build({
write: true,
bundle: true,
minify: true,
format: 'esm',
entryPoints: [libEntry],
outfile: bundleEntry,
});
benches.push({
libName,
libEntry,
execEntry,
bundleEntry,
});
}
console.log('\nExecuting QuickJS benchmark...\n');
let args = process.argv.slice(2).join(' ');
for (let bench of benches) {
console.log(`--- ${bench.libName} ---\n`);
await $({ stdio: 'inherit' })`qjs ${args} ${bench.execEntry}`;
}