aboutsummaryrefslogtreecommitdiff
path: root/bench/snippets/runner.mjs
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-05-10 21:37:08 -0700
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-05-10 21:37:08 -0700
commite1c6adc73700aaa9012a1e40b022af3e3df8a9ad (patch)
treee8f8abeec757299e3d3f6ca85d3e82a080b261ae /bench/snippets/runner.mjs
parent5e0eedccb06a6991e48220bd4df703d725f65e83 (diff)
downloadbun-e1c6adc73700aaa9012a1e40b022af3e3df8a9ad.tar.gz
bun-e1c6adc73700aaa9012a1e40b022af3e3df8a9ad.tar.zst
bun-e1c6adc73700aaa9012a1e40b022af3e3df8a9ad.zip
Prepare to run these automatically
Diffstat (limited to 'bench/snippets/runner.mjs')
-rw-r--r--bench/snippets/runner.mjs22
1 files changed, 22 insertions, 0 deletions
diff --git a/bench/snippets/runner.mjs b/bench/snippets/runner.mjs
new file mode 100644
index 000000000..4f6e29fba
--- /dev/null
+++ b/bench/snippets/runner.mjs
@@ -0,0 +1,22 @@
+import * as Mitata from "../node_modules/mitata/src/cli.mjs";
+import process from "node:process";
+
+const asJSON = !!process?.env?.BENCHMARK_RUNNER;
+
+export function run(opts = {}) {
+ opts ??= {};
+
+ if (asJSON) {
+ opts.json = true;
+ }
+
+ return Mitata.run(opts);
+}
+
+export function bench(name, fn) {
+ return Mitata.bench(name, fn);
+}
+
+export function group(name, fn) {
+ return Mitata.group(name, fn);
+}