diff --git a/.buildkite/scripts/upload-release.sh b/.buildkite/scripts/upload-release.sh index 68b9af307cc4f2..83d70d5730dca3 100755 --- a/.buildkite/scripts/upload-release.sh +++ b/.buildkite/scripts/upload-release.sh @@ -162,6 +162,25 @@ function upload_s3_file() { run_command aws --endpoint-url="$AWS_ENDPOINT" s3 cp "$file" "s3://$AWS_BUCKET/$folder/$file" } +function send_bench_webhook() { + if [ -z "$BENCHMARK_URL" ]; then + return 1 + fi + + local tag="$1" + local commit="$BUILDKITE_COMMIT" + local artifact_path="${commit}" + + if [ "$tag" == "canary" ]; then + artifact_path="${commit}-canary" + fi + + local artifact_url="https://pub-5e11e972747a44bf9aaf9394f185a982.r2.dev/releases/$artifact_path/bun-linux-x64.zip" + local webhook_url="$BENCHMARK_URL?tag=$tag&commit=$commit&artifact_url=$artifact_url" + + curl -X POST "$webhook_url" +} + function create_release() { assert_main assert_buildkite_agent @@ -206,6 +225,7 @@ function create_release() { update_github_release "$tag" create_sentry_release "$tag" + send_bench_webhook "$tag" } function assert_canary() { diff --git a/bench/async/bun.js b/bench/async/bun.js index e99e05a2dc22ab..b5f91da558995d 100644 --- a/bench/async/bun.js +++ b/bench/async/bun.js @@ -1,4 +1,4 @@ -import { bench, run } from "mitata"; +import { bench, run } from "../runner.mjs"; bench("sync", () => {}); bench("async", async () => {}); diff --git a/bench/async/deno.js b/bench/async/deno.js index 4e691a1cdb2382..b5f91da558995d 100644 --- a/bench/async/deno.js +++ b/bench/async/deno.js @@ -1,4 +1,4 @@ -import { bench, run } from "../node_modules/mitata/src/cli.mjs"; +import { bench, run } from "../runner.mjs"; bench("sync", () => {}); bench("async", async () => {}); diff --git a/bench/async/node.mjs b/bench/async/node.mjs index e99e05a2dc22ab..b5f91da558995d 100644 --- a/bench/async/node.mjs +++ b/bench/async/node.mjs @@ -1,4 +1,4 @@ -import { bench, run } from "mitata"; +import { bench, run } from "../runner.mjs"; bench("sync", () => {}); bench("async", async () => {}); diff --git a/bench/bun.lockb b/bench/bun.lockb index 6704d645425760..e77a3b406cbb3b 100755 Binary files a/bench/bun.lockb and b/bench/bun.lockb differ diff --git a/bench/copyfile/node.mitata.mjs b/bench/copyfile/node.mitata.mjs index 90bf6fe0f649b0..de0e76beabfdeb 100644 --- a/bench/copyfile/node.mitata.mjs +++ b/bench/copyfile/node.mitata.mjs @@ -1,5 +1,5 @@ -import { bench, run } from "mitata"; import { copyFileSync, statSync, writeFileSync } from "node:fs"; +import { bench, run } from "../runner.mjs"; function runner(ready) { for (let size of [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000]) { diff --git a/bench/crypto/asymmetricCipher.js b/bench/crypto/asymmetricCipher.js index 4f7c623b7dd0a7..7fa92b20e0d187 100644 --- a/bench/crypto/asymmetricCipher.js +++ b/bench/crypto/asymmetricCipher.js @@ -1,4 +1,4 @@ -import { bench, run } from "mitata"; +import { bench, run } from "../runner.mjs"; const crypto = require("node:crypto"); const keyPair = crypto.generateKeyPairSync("rsa", { diff --git a/bench/crypto/asymmetricSign.js b/bench/crypto/asymmetricSign.js index fe0f1464595a72..e00634963e162b 100644 --- a/bench/crypto/asymmetricSign.js +++ b/bench/crypto/asymmetricSign.js @@ -1,4 +1,4 @@ -import { bench, run } from "mitata"; +import { bench, run } from "../runner.mjs"; const crypto = require("node:crypto"); const keyPair = crypto.generateKeyPairSync("rsa", { diff --git a/bench/deepEqual/map.js b/bench/deepEqual/map.js index 51070e466fcede..3d89d61eea59e1 100644 --- a/bench/deepEqual/map.js +++ b/bench/deepEqual/map.js @@ -1,5 +1,5 @@ import { expect } from "bun:test"; -import { bench, run } from "mitata"; +import { bench, run } from "../runner.mjs"; const MAP_SIZE = 10_000; diff --git a/bench/deepEqual/set.js b/bench/deepEqual/set.js index 4deef8847bbf39..1f16d09e9c6f3c 100644 --- a/bench/deepEqual/set.js +++ b/bench/deepEqual/set.js @@ -1,5 +1,5 @@ import { expect } from "bun:test"; -import { bench, run } from "mitata"; +import { bench, run } from "../runner.mjs"; const SET_SIZE = 10_000; diff --git a/bench/emitter/implementations.mjs b/bench/emitter/implementations.mjs index a925bdce789726..abf025645f4ff2 100644 --- a/bench/emitter/implementations.mjs +++ b/bench/emitter/implementations.mjs @@ -1,5 +1,5 @@ -import { group } from "mitata"; import EventEmitterNative from "node:events"; +import { group } from "../runner.mjs"; export const implementations = [ { diff --git a/bench/emitter/microbench.mjs b/bench/emitter/microbench.mjs index eae59d4c19e313..4f3ebb465de1b9 100644 --- a/bench/emitter/microbench.mjs +++ b/bench/emitter/microbench.mjs @@ -1,4 +1,4 @@ -import { bench, run } from "mitata"; +import { bench, run } from "../runner.mjs"; import { groupForEmitter } from "./implementations.mjs"; var id = 0; diff --git a/bench/emitter/microbench_once.mjs b/bench/emitter/microbench_once.mjs index b24fb210310274..fa5ca9496a8893 100644 --- a/bench/emitter/microbench_once.mjs +++ b/bench/emitter/microbench_once.mjs @@ -1,4 +1,4 @@ -import { bench, run } from "mitata"; +import { bench, run } from "../runner.mjs"; import { groupForEmitter } from "./implementations.mjs"; var id = 0; diff --git a/bench/emitter/realworld_stream.mjs b/bench/emitter/realworld_stream.mjs index 1b2d19945b7cb4..6d2428df24101a 100644 --- a/bench/emitter/realworld_stream.mjs +++ b/bench/emitter/realworld_stream.mjs @@ -1,4 +1,4 @@ -import { bench, run } from "mitata"; +import { bench, run } from "../runner.mjs"; import { groupForEmitter } from "./implementations.mjs"; // Pseudo RNG is derived from https://stackoverflow.com/a/424445 diff --git a/bench/fetch/bun.js b/bench/fetch/bun.js index 96e7275a855352..1241aa7d4f2d0e 100644 --- a/bench/fetch/bun.js +++ b/bench/fetch/bun.js @@ -1,4 +1,4 @@ -import { bench, run } from "mitata"; +import { bench, run } from "../runner.mjs"; const count = 100; diff --git a/bench/fetch/node.mjs b/bench/fetch/node.mjs index 96e7275a855352..1241aa7d4f2d0e 100644 --- a/bench/fetch/node.mjs +++ b/bench/fetch/node.mjs @@ -1,4 +1,4 @@ -import { bench, run } from "mitata"; +import { bench, run } from "../runner.mjs"; const count = 100; diff --git a/bench/ffi/bun.js b/bench/ffi/bun.js index bceebc20b95599..5ef13e234adabf 100644 --- a/bench/ffi/bun.js +++ b/bench/ffi/bun.js @@ -1,5 +1,5 @@ import { CString, dlopen, ptr } from "bun:ffi"; -import { bench, group, run } from "mitata"; +import { bench, group, run } from "../runner.mjs"; const { napiNoop, napiHash, napiString } = require(import.meta.dir + "/src/ffi_napi_bench.node"); diff --git a/bench/ffi/deno.js b/bench/ffi/deno.js index 72d0a849b823be..a1e7ae0ee44e45 100644 --- a/bench/ffi/deno.js +++ b/bench/ffi/deno.js @@ -1,4 +1,4 @@ -import { bench, group, run } from "../node_modules/mitata/src/cli.mjs"; +import { bench, group, run } from "../runner.mjs"; const extension = "darwin" !== Deno.build.os ? "so" : "dylib"; const path = new URL("src/target/release/libffi_napi_bench." + extension, import.meta.url).pathname; diff --git a/bench/ffi/node.mjs b/bench/ffi/node.mjs index db743024b81b19..c6c9f67c3d95cb 100644 --- a/bench/ffi/node.mjs +++ b/bench/ffi/node.mjs @@ -1,5 +1,5 @@ -import { bench, group, run } from "mitata"; import { createRequire } from "node:module"; +import { bench, group, run } from "../runner.mjs"; const require = createRequire(import.meta.url); const { napiNoop, napiHash, napiString } = require("./src/ffi_napi_bench.node"); diff --git a/bench/glob/braces.mjs b/bench/glob/braces.mjs index 2e4a9c1c21e9d3..fa676142595c9a 100644 --- a/bench/glob/braces.mjs +++ b/bench/glob/braces.mjs @@ -1,5 +1,5 @@ import braces from "braces"; -import { bench, group, run } from "mitata"; +import { bench, group, run } from "../runner.mjs"; // const iterations = 1000; const iterations = 100; @@ -10,15 +10,16 @@ const veryComplexPattern = "{a,b,HI{c,e,LMAO{d,f}Q}}{1,2,{3,4},5}"; console.log(braces(complexPattern, { expand: true })); function benchPattern(pattern, name) { - group({ name: `${name} pattern: "${pattern}"`, summary: true }, () => { + const _name = `${name} pattern: "${pattern}"`; + group({ name: _name, summary: true }, () => { if (typeof Bun !== "undefined") - bench("Bun", () => { + bench(`Bun (${_name})`, () => { for (let i = 0; i < iterations; i++) { Bun.$.braces(pattern); } }); - bench("micromatch/braces", () => { + bench(`micromatch/braces ${_name}`, () => { for (let i = 0; i < iterations; i++) { braces(pattern, { expand: true }); } diff --git a/bench/glob/match.mjs b/bench/glob/match.mjs index 66150daf25449f..c81a972c41ae85 100644 --- a/bench/glob/match.mjs +++ b/bench/glob/match.mjs @@ -1,5 +1,5 @@ import micromatch from "micromatch"; -import { bench, run } from "mitata"; +import { bench, run } from "../runner.mjs"; const Glob = typeof Bun !== "undefined" ? Bun.Glob : undefined; const doMatch = typeof Bun === "undefined" ? micromatch.isMatch : (a, b) => new Glob(b).match(a); diff --git a/bench/glob/scan.mjs b/bench/glob/scan.mjs index ce6721a16fcf84..b5292eba1e4d6c 100644 --- a/bench/glob/scan.mjs +++ b/bench/glob/scan.mjs @@ -1,6 +1,6 @@ import fg from "fast-glob"; import { fdir } from "fdir"; -import { bench, group, run } from "mitata"; +import { bench, group, run } from "../runner.mjs"; const normalPattern = "*.ts"; const recursivePattern = "**/*.ts"; diff --git a/bench/gzip/bun.js b/bench/gzip/bun.js index cfe8615f80438b..6b7b66cb666763 100644 --- a/bench/gzip/bun.js +++ b/bench/gzip/bun.js @@ -1,5 +1,5 @@ import { gunzipSync, gzipSync } from "bun"; -import { bench, group, run } from "mitata"; +import { bench, group, run } from "../runner.mjs"; const data = await Bun.file(require.resolve("@babel/standalone/babel.min.js")).arrayBuffer(); diff --git a/bench/gzip/deno.js b/bench/gzip/deno.js index 0c7f73b37cd339..fa425e917a8344 100644 --- a/bench/gzip/deno.js +++ b/bench/gzip/deno.js @@ -1,4 +1,4 @@ -import { bench, run } from "../node_modules/mitata/src/cli.mjs"; +import { bench, run } from "../runner.mjs"; const data = new TextEncoder().encode("Hello World!".repeat(9999)); diff --git a/bench/gzip/node.mjs b/bench/gzip/node.mjs index 4d1125b36865be..f4c867ce58734e 100644 --- a/bench/gzip/node.mjs +++ b/bench/gzip/node.mjs @@ -1,7 +1,7 @@ import { readFileSync } from "fs"; -import { bench, run } from "mitata"; import { createRequire } from "module"; import { gunzipSync, gzipSync } from "zlib"; +import { bench, run } from "../runner.mjs"; const require = createRequire(import.meta.url); const data = readFileSync(require.resolve("@babel/standalone/babel.min.js")); diff --git a/bench/log/bun.js b/bench/log/bun.js index 43728fd648fee8..3e78eb4206495e 100644 --- a/bench/log/bun.js +++ b/bench/log/bun.js @@ -1,4 +1,4 @@ -import { bench, run } from "mitata"; +import { bench, run } from "../runner.mjs"; bench("console.log('hello')", () => console.log("hello")); bench("console.log({ hello: 'object' })", () => console.log({ hello: "object" })); diff --git a/bench/log/deno.mjs b/bench/log/deno.mjs index 24d72446335142..4bfa1a3cc2f7c7 100644 --- a/bench/log/deno.mjs +++ b/bench/log/deno.mjs @@ -1,4 +1,4 @@ -import { bench, run } from "../node_modules/mitata/src/cli.mjs"; +import { bench, run } from "../runner.mjs"; bench("console.log", () => console.log("hello")); bench("console.log({ hello: 'object' })", () => console.log({ hello: "object" })); diff --git a/bench/log/node.mjs b/bench/log/node.mjs index 6ec73f7438e3ae..4bfa1a3cc2f7c7 100644 --- a/bench/log/node.mjs +++ b/bench/log/node.mjs @@ -1,4 +1,4 @@ -import { bench, run } from "mitata"; +import { bench, run } from "../runner.mjs"; bench("console.log", () => console.log("hello")); bench("console.log({ hello: 'object' })", () => console.log({ hello: "object" })); diff --git a/bench/modules/node_os/bun.js b/bench/modules/node_os/bun.js index 4405c9a45688dc..713f9483a9a7cd 100644 --- a/bench/modules/node_os/bun.js +++ b/bench/modules/node_os/bun.js @@ -1,4 +1,4 @@ -import { bench, run } from "mitata"; +import { bench, run } from "../../runner.mjs"; import { arch, cpus, diff --git a/bench/modules/node_os/node.mjs b/bench/modules/node_os/node.mjs index 4405c9a45688dc..36139b29eff5e7 100644 --- a/bench/modules/node_os/node.mjs +++ b/bench/modules/node_os/node.mjs @@ -1,4 +1,3 @@ -import { bench, run } from "mitata"; import { arch, cpus, @@ -19,6 +18,7 @@ import { userInfo, version, } from "node:os"; +import { bench, run } from "../../runner.mjs"; bench("cpus()", () => cpus()); bench("networkInterfaces()", () => networkInterfaces()); diff --git a/bench/package.json b/bench/package.json index 11b0ab69bd1aff..a80d7566dc6650 100644 --- a/bench/package.json +++ b/bench/package.json @@ -13,7 +13,9 @@ "execa": "^8.0.1", "fast-glob": "3.3.1", "fdir": "^6.1.0", - "mitata": "^0.1.6", + "mitata": "^1.0.10", + "react": "^18.3.1", + "react-dom": "^18.3.1", "string-width": "7.1.0", "tinycolor2": "^1.6.0", "zx": "^7.2.3" diff --git a/bench/runner.mjs b/bench/runner.mjs new file mode 100644 index 00000000000000..9f6bcee16f20b3 --- /dev/null +++ b/bench/runner.mjs @@ -0,0 +1,19 @@ +import * as Mitata from "mitata"; +import process from "node:process"; + +const asJSON = !!process?.env?.BENCHMARK_RUNNER; + +/** @param {Parameters["0"]} opts */ +export function run(opts = {}) { + if (asJSON) { + opts.format = "json"; + } + + return Mitata.run(opts); +} + +export const bench = Mitata.bench; + +export function group(_name, fn) { + return Mitata.group(fn); +} diff --git a/bench/snippets/array-arguments-slice.mjs b/bench/snippets/array-arguments-slice.mjs index 5d1139b8b3681d..8470ab79a6b707 100644 --- a/bench/snippets/array-arguments-slice.mjs +++ b/bench/snippets/array-arguments-slice.mjs @@ -1,4 +1,4 @@ -import { bench, run } from "./runner.mjs"; +import { bench, run } from "../runner.mjs"; function doIt(...args) { // we use .at() to prevent constant folding optimizations diff --git a/bench/snippets/array-map.mjs b/bench/snippets/array-map.mjs index 7b8bc6fdcf2f97..b467e9cd3e4842 100644 --- a/bench/snippets/array-map.mjs +++ b/bench/snippets/array-map.mjs @@ -1,5 +1,5 @@ // https://github.com/oven-sh/bun/issues/1096 -import { bench, run } from "./runner.mjs"; +import { bench, run } from "../runner.mjs"; const identity = x => x; diff --git a/bench/snippets/array-shift.mjs b/bench/snippets/array-shift.mjs index 7039026706f5f9..15733f940bd736 100644 --- a/bench/snippets/array-shift.mjs +++ b/bench/snippets/array-shift.mjs @@ -1,4 +1,4 @@ -import { bench, run } from "./runner.mjs"; +import { bench, run } from "../runner.mjs"; var myArray = new Array(5); bench("[1, 2, 3, 4, 5].shift()", () => { diff --git a/bench/snippets/array-sort.mjs b/bench/snippets/array-sort.mjs index 9ed257740e7099..8951d716a64f14 100644 --- a/bench/snippets/array-sort.mjs +++ b/bench/snippets/array-sort.mjs @@ -1,4 +1,4 @@ -import { bench, run } from "./runner.mjs"; +import { bench, run } from "../runner.mjs"; var comparator = (a, b) => a - b; const numbers = [ diff --git a/bench/snippets/arraybuffersink.mjs b/bench/snippets/arraybuffersink.mjs index f90fae69fd04a8..566f9bd6302876 100644 --- a/bench/snippets/arraybuffersink.mjs +++ b/bench/snippets/arraybuffersink.mjs @@ -1,6 +1,6 @@ // @runtime bun import { ArrayBufferSink } from "bun"; -import { bench, run } from "./runner.mjs"; +import { bench, run } from "../runner.mjs"; var short = "Hello World!"; var shortUTF16 = "Hello World 💕💕💕"; diff --git a/bench/snippets/assert.mjs b/bench/snippets/assert.mjs index 120363aa07e86e..7ed8cf7596eabd 100644 --- a/bench/snippets/assert.mjs +++ b/bench/snippets/assert.mjs @@ -1,5 +1,5 @@ import * as assert from "assert"; -import { bench, run } from "./runner.mjs"; +import { bench, run } from "../runner.mjs"; bench("deepEqual", () => { assert.deepEqual({ foo: "123", bar: "baz" }, { foo: "123", bar: "baz" }); diff --git a/bench/snippets/async-overhead.mjs b/bench/snippets/async-overhead.mjs index e285c7edd6f3c6..ec171dae54c626 100644 --- a/bench/snippets/async-overhead.mjs +++ b/bench/snippets/async-overhead.mjs @@ -1,4 +1,4 @@ -import { bench, run } from "mitata"; +import { bench, run } from "../runner.mjs"; bench("noop", function () {}); bench("async function(){}", async function () {}); diff --git a/bench/snippets/atob.mjs b/bench/snippets/atob.mjs index 3a848300c0e5a7..de7d128265e4a4 100644 --- a/bench/snippets/atob.mjs +++ b/bench/snippets/atob.mjs @@ -1,4 +1,4 @@ -import { bench, run } from "./runner.mjs"; +import { bench, run } from "../runner.mjs"; function makeBenchmark(size) { const latin1 = btoa("A".repeat(size)); diff --git a/bench/snippets/blob.mjs b/bench/snippets/blob.mjs index 68ebc1ce4d2591..7486f56fc93757 100644 --- a/bench/snippets/blob.mjs +++ b/bench/snippets/blob.mjs @@ -1,4 +1,4 @@ -import { bench, run } from "../node_modules/mitata/src/cli.mjs"; +import { bench, run } from "../runner.mjs"; bench("new Blob(['hello world'])", function () { return new Blob(["hello world"]); diff --git a/bench/snippets/buffer-base64.mjs b/bench/snippets/buffer-base64.mjs index 96bab6f039a1da..73dc3bccf860b2 100644 --- a/bench/snippets/buffer-base64.mjs +++ b/bench/snippets/buffer-base64.mjs @@ -1,4 +1,4 @@ -import { bench, run } from "./runner.mjs"; +import { bench, run } from "../runner.mjs"; function makeBenchmark(size, isToString) { const base64Input = Buffer.alloc(size, "latin1").toString("base64"); diff --git a/bench/snippets/buffer-concat.mjs b/bench/snippets/buffer-concat.mjs index 0a6e4a0c85b945..c2812796a7d5dd 100644 --- a/bench/snippets/buffer-concat.mjs +++ b/bench/snippets/buffer-concat.mjs @@ -1,4 +1,4 @@ -import { bench, run } from "./runner.mjs"; +import { bench, run } from "../runner.mjs"; for (let size of [32, 2048, 1024 * 16, 1024 * 1024 * 2, 1024 * 1024 * 16]) { const first = Buffer.allocUnsafe(size); diff --git a/bench/snippets/buffer-create.mjs b/bench/snippets/buffer-create.mjs index 0093f6de8324d4..ded7f02cab7d60 100644 --- a/bench/snippets/buffer-create.mjs +++ b/bench/snippets/buffer-create.mjs @@ -1,7 +1,7 @@ // @runtime bun,node,deno import { Buffer } from "node:buffer"; import process from "node:process"; -import { bench, run } from "./runner.mjs"; +import { bench, run } from "../runner.mjs"; const N = parseInt(process.env.RUN_COUNTER ?? "10000", 10); var isBuffer = new Buffer(0); diff --git a/bench/snippets/buffer-fill.mjs b/bench/snippets/buffer-fill.mjs index e67e32eb1bef06..47b5babbc42189 100644 --- a/bench/snippets/buffer-fill.mjs +++ b/bench/snippets/buffer-fill.mjs @@ -1,4 +1,4 @@ -import { bench, run } from "./runner.mjs"; +import { bench, run } from "../runner.mjs"; for (let size of [32, 2048, 1024 * 16, 1024 * 1024 * 2, 1024 * 1024 * 16]) { for (let fillSize of [4, 8, 16, 11]) { diff --git a/bench/snippets/buffer-to-string.mjs b/bench/snippets/buffer-to-string.mjs index f59470f6fafa4a..2d26535838ad16 100644 --- a/bench/snippets/buffer-to-string.mjs +++ b/bench/snippets/buffer-to-string.mjs @@ -1,6 +1,6 @@ import { Buffer } from "node:buffer"; import crypto from "node:crypto"; -import { bench, run } from "./runner.mjs"; +import { bench, run } from "../runner.mjs"; const bigBuffer = Buffer.from("hello world".repeat(10000)); const converted = bigBuffer.toString("base64"); diff --git a/bench/snippets/color.mjs b/bench/snippets/color.mjs index 14b12356b97115..4a505630fc0a54 100644 --- a/bench/snippets/color.mjs +++ b/bench/snippets/color.mjs @@ -1,22 +1,22 @@ import Color from "color"; import tinycolor from "tinycolor2"; -import { bench, group, run } from "./runner.mjs"; +import { bench, group, run } from "../runner.mjs"; const inputs = ["#f00", "rgb(255, 0, 0)", "rgba(255, 0, 0, 1)", "hsl(0, 100%, 50%)"]; for (const input of inputs) { group(`${input}`, () => { if (typeof Bun !== "undefined") { - bench("Bun.color()", () => { + bench(`Bun.color() (${input})`, () => { Bun.color(input, "css"); }); } - bench("color", () => { + bench(`color (${input})`, () => { Color(input).hex(); }); - bench("'tinycolor2'", () => { + bench(`'tinycolor2' (${input})`, () => { tinycolor(input).toHexString(); }); }); diff --git a/bench/snippets/concat.js b/bench/snippets/concat.js index 85a15c28964aa9..15e418f05ec85f 100644 --- a/bench/snippets/concat.js +++ b/bench/snippets/concat.js @@ -1,6 +1,6 @@ import { allocUnsafe } from "bun"; import { readFileSync } from "fs"; -import { bench, group, run } from "./runner.mjs"; +import { bench, group, run } from "../runner.mjs"; function polyfill(chunks) { var size = 0; @@ -41,15 +41,16 @@ const chunkGroups = [ ]; for (const chunks of chunkGroups) { - group(`${chunks.reduce((prev, curr, i, a) => prev + curr.byteLength, 0)} bytes for ${chunks.length} chunks`, () => { - bench("Bun.concatArrayBuffers", () => { + const name = `${chunks.reduce((prev, curr, i, a) => prev + curr.byteLength, 0)} bytes for ${chunks.length} chunks` + group(name, () => { + bench(`Bun.concatArrayBuffers (${name})`, () => { Bun.concatArrayBuffers(chunks); }); - bench("Uint8Array.set", () => { + bench(`Uint8Array.set (${name})`, () => { polyfill(chunks); }); - bench("Uint8Array.set (uninitialized memory)", () => { + bench(`Uint8Array.set (uninitialized memory) (${name})`, () => { polyfillUninitialized(chunks); }); }); diff --git a/bench/snippets/console-log.mjs b/bench/snippets/console-log.mjs index b95533f0129f27..274af84d67875b 100644 --- a/bench/snippets/console-log.mjs +++ b/bench/snippets/console-log.mjs @@ -1,4 +1,4 @@ -import { bench, run } from "../node_modules/mitata/src/cli.mjs"; +import { bench, run } from "../runner.mjs"; const json = { login: "wongmjane", diff --git a/bench/snippets/cp.mjs b/bench/snippets/cp.mjs index 898375439fc4eb..1572296e626801 100644 --- a/bench/snippets/cp.mjs +++ b/bench/snippets/cp.mjs @@ -2,7 +2,7 @@ import { mkdirSync, rmSync, writeFileSync } from "fs"; import { cp } from "fs/promises"; import { tmpdir } from "os"; import { join, resolve } from "path"; -import { bench, run } from "./runner.mjs"; +import { bench, run } from "../runner.mjs"; import { fileURLToPath } from "url"; const hugeDirectory = (() => { diff --git a/bench/snippets/crypto-2190.mjs b/bench/snippets/crypto-2190.mjs index dab54f1fdfd4ae..1ff65367886b56 100644 --- a/bench/snippets/crypto-2190.mjs +++ b/bench/snippets/crypto-2190.mjs @@ -1,6 +1,6 @@ // https://github.com/oven-sh/bun/issues/2190 -import { bench, run } from "mitata"; import { createHash } from "node:crypto"; +import { bench, run } from "../runner.mjs"; const data = "Delightful remarkably mr on announcing themselves entreaties favourable. About to in so terms voice at. Equal an would is found seems of. The particular friendship one sufficient terminated frequently themselves. It more shed went up is roof if loud case. Delay music in lived noise an. Beyond genius really enough passed is up."; diff --git a/bench/snippets/crypto-hasher.mjs b/bench/snippets/crypto-hasher.mjs index 36f67739ad0dbb..e08e3607538ac2 100644 --- a/bench/snippets/crypto-hasher.mjs +++ b/bench/snippets/crypto-hasher.mjs @@ -1,5 +1,5 @@ // so it can run in environments without node module resolution -import { bench, run } from "./runner.mjs"; +import { bench, run } from "../runner.mjs"; import crypto from "node:crypto"; diff --git a/bench/snippets/crypto-randomUUID.mjs b/bench/snippets/crypto-randomUUID.mjs index f6a4c0aa68faf3..f8faeb6c9ed30b 100644 --- a/bench/snippets/crypto-randomUUID.mjs +++ b/bench/snippets/crypto-randomUUID.mjs @@ -1,4 +1,4 @@ -import { bench, run } from "./runner.mjs"; +import { bench, run } from "../runner.mjs"; bench("crypto.randomUUID()", () => { return crypto.randomUUID(); diff --git a/bench/snippets/crypto-stream.mjs b/bench/snippets/crypto-stream.mjs index 3560563d9db8f6..f931f2ed73aa69 100644 --- a/bench/snippets/crypto-stream.mjs +++ b/bench/snippets/crypto-stream.mjs @@ -1,6 +1,6 @@ // https://github.com/oven-sh/bun/issues/2190 -import { bench, run } from "mitata"; import { createHash } from "node:crypto"; +import { bench, run } from "../runner.mjs"; const data = "Delightful remarkably mr on announcing themselves entreaties favourable. About to in so terms voice at. Equal an would is found seems of. The particular friendship one sufficient terminated frequently themselves. It more shed went up is roof if loud case. Delay music in lived noise an. Beyond genius really enough passed is up."; diff --git a/bench/snippets/crypto.mjs b/bench/snippets/crypto.mjs index 7c49fe92ee3e2e..c285722056b9e6 100644 --- a/bench/snippets/crypto.mjs +++ b/bench/snippets/crypto.mjs @@ -1,6 +1,6 @@ // so it can run in environments without node module resolution import crypto from "node:crypto"; -import { bench, run } from "../node_modules/mitata/src/cli.mjs"; +import { bench, run } from "../runner.mjs"; var foo = new Uint8Array(65536); bench("crypto.getRandomValues(65536)", () => { crypto.getRandomValues(foo); diff --git a/bench/snippets/deep-equals.js b/bench/snippets/deep-equals.js index 0b6949234223ac..87d68ce030abd2 100644 --- a/bench/snippets/deep-equals.js +++ b/bench/snippets/deep-equals.js @@ -1,5 +1,5 @@ import fastDeepEquals from "fast-deep-equal/es6/index"; -import { bench, group, run } from "./runner.mjs"; +import { bench, group, run } from "../runner.mjs"; // const Date = globalThis.Date; function func1() {} @@ -490,7 +490,7 @@ for (let { tests, description } of fixture) { var expected; group(describe, () => { for (let equalsFn of [Bun.deepEquals, fastDeepEquals]) { - bench(equalsFn.name, () => { + bench(`${describe}: ${equalsFn.name}`, () => { expected = equalsFn(value1, value2); if (expected !== equal) { throw new Error(`Expected ${expected} to be ${equal} for ${description}`); diff --git a/bench/snippets/define-properties.mjs b/bench/snippets/define-properties.mjs index 6a10ab183220e5..f26d3c718858bf 100644 --- a/bench/snippets/define-properties.mjs +++ b/bench/snippets/define-properties.mjs @@ -1,4 +1,4 @@ -import { bench, run } from "../node_modules/mitata/src/cli.mjs"; +import { bench, run } from "../runner.mjs"; const properties = { closed: { diff --git a/bench/snippets/dns.node.mjs b/bench/snippets/dns.node.mjs index ffa58ff236509c..fe065edf06345b 100644 --- a/bench/snippets/dns.node.mjs +++ b/bench/snippets/dns.node.mjs @@ -1,5 +1,5 @@ import { lookup, resolve } from "node:dns/promises"; -import { bench, run } from "./runner.mjs"; +import { bench, run } from "../runner.mjs"; bench("(cached) dns.lookup remote x 50", async () => { var tld = "example.com"; diff --git a/bench/snippets/dns.ts b/bench/snippets/dns.ts index 12ecfe1198b986..cb350a808d8f06 100644 --- a/bench/snippets/dns.ts +++ b/bench/snippets/dns.ts @@ -1,10 +1,10 @@ import { dns } from "bun"; -import { bench, group, run } from "./runner.mjs"; +import { bench, group, run } from "../runner.mjs"; async function forEachBackend(name, fn) { group(name, () => { for (let backend of ["libc", "c-ares", process.platform === "darwin" ? "system" : ""].filter(Boolean)) - bench(backend, fn(backend)); + bench(`${backend} (${name})`, fn(backend)); }); } diff --git a/bench/snippets/encode-into.mjs b/bench/snippets/encode-into.mjs index 70cb242f36f83b..20ac486bad218f 100644 --- a/bench/snippets/encode-into.mjs +++ b/bench/snippets/encode-into.mjs @@ -1,4 +1,4 @@ -import { bench, run } from "../node_modules/mitata/src/cli.mjs"; +import { bench, run } from "../runner.mjs"; const encoder = new TextEncoder(); diff --git a/bench/snippets/error-capturestack.mjs b/bench/snippets/error-capturestack.mjs index 0c59ff9c84aa58..3b715b39618f47 100644 --- a/bench/snippets/error-capturestack.mjs +++ b/bench/snippets/error-capturestack.mjs @@ -1,4 +1,4 @@ -import { bench, run } from "./runner.mjs"; +import { bench, run } from "../runner.mjs"; var err = new Error(); bench("Error.captureStackTrace(err)", () => { diff --git a/bench/snippets/escapeHTML.js b/bench/snippets/escapeHTML.js index 96da26d9738e8a..48b12bf61d2ec4 100644 --- a/bench/snippets/escapeHTML.js +++ b/bench/snippets/escapeHTML.js @@ -1,4 +1,4 @@ -import { bench, group, run } from "./runner.mjs"; +import { bench, group, run } from "../runner.mjs"; var bunEscapeHTML = globalThis.escapeHTML || Bun.escapeHTML; @@ -92,24 +92,21 @@ function reactEscapeHtml(string) { // } for (let input of [ - `long string, nothing to escape... `.repeat(9999999 * 3), + "long string, nothing to escape... ".repeat(9999999 * 3), FIXTURE.repeat(8000), // "[unicode]" + FIXTURE_WITH_UNICODE, ]) { + const name = `"${input.substring(0, Math.min(input.length, 32))}" (${new Intl.NumberFormat().format(input.length / 100_000_000_0)} GB)` group( { summary: true, - name: - `"` + - input.substring(0, Math.min(input.length, 32)) + - `"` + - ` (${new Intl.NumberFormat().format(input.length / 100_000_000_0)} GB)`, + name }, () => { // bench(`ReactDOM.escapeHTML`, () => reactEscapeHtml(input)); // bench(`html-entities.encode`, () => htmlEntityEncode(input)); // bench(`he.escape`, () => heEscape(input)); - bench(`Bun.escapeHTML`, () => bunEscapeHTML(input)); + bench(`Bun.escapeHTML (${name})`, () => bunEscapeHTML(input)); }, ); } diff --git a/bench/snippets/ffi-overhead.mjs b/bench/snippets/ffi-overhead.mjs index fed3228574e3c2..d0f11e907c9032 100644 --- a/bench/snippets/ffi-overhead.mjs +++ b/bench/snippets/ffi-overhead.mjs @@ -1,5 +1,5 @@ import { dlopen } from "bun:ffi"; -import { bench, group, run } from "./runner.mjs"; +import { bench, group, run } from "../runner.mjs"; const types = { returns_true: { diff --git a/bench/snippets/form-data.mjs b/bench/snippets/form-data.mjs index a12cf4b134c4d7..b78edbfbe74ad1 100644 --- a/bench/snippets/form-data.mjs +++ b/bench/snippets/form-data.mjs @@ -1,5 +1,5 @@ // so it can run in environments without node module resolution -import { bench, run } from "../node_modules/mitata/src/cli.mjs"; +import { bench, run } from "../runner.mjs"; const blob = new Blob(["foo", "bar", "baz"]); bench("FormData.append", () => { diff --git a/bench/snippets/headers.mjs b/bench/snippets/headers.mjs index 7057db02a742b8..8c0c0ec4503e51 100644 --- a/bench/snippets/headers.mjs +++ b/bench/snippets/headers.mjs @@ -1,4 +1,4 @@ -import { bench, run } from "../node_modules/mitata/src/cli.mjs"; +import { bench, run } from "../runner.mjs"; // pure JS implementation will optimze this out bench("new Headers", function () { diff --git a/bench/snippets/index-of.mjs b/bench/snippets/index-of.mjs index 04b9704e96170c..8f22ab35185d08 100644 --- a/bench/snippets/index-of.mjs +++ b/bench/snippets/index-of.mjs @@ -1,4 +1,4 @@ -import { bench, run } from "./runner.mjs"; +import { bench, run } from "../runner.mjs"; const input = "Hello, World! foo bar baz qux quux corge grault garply waldo fred plugh xyzzy thud z a b c d e f g h i j k l m n o p q r s t u v w x y z".split( diff --git a/bench/snippets/json-parse-stringify.mjs b/bench/snippets/json-parse-stringify.mjs index c58041e100adb6..f516f5364c6bfc 100644 --- a/bench/snippets/json-parse-stringify.mjs +++ b/bench/snippets/json-parse-stringify.mjs @@ -1,4 +1,4 @@ -import { bench, run } from "./runner.mjs"; +import { bench, run } from "../runner.mjs"; var obj = { "restApiRoot": "/api", diff --git a/bench/json-stringify/bun.js b/bench/snippets/json-stringify.js similarity index 83% rename from bench/json-stringify/bun.js rename to bench/snippets/json-stringify.js index 22f29deb405a42..e50ab7be10cadd 100644 --- a/bench/json-stringify/bun.js +++ b/bench/snippets/json-stringify.js @@ -1,4 +1,4 @@ -import { bench, run } from "mitata"; +import { bench, run } from "../runner.mjs"; bench("JSON.stringify({hello: 'world'})", () => JSON.stringify({ hello: "world" })); diff --git a/bench/snippets/module-exports-putter.cjs b/bench/snippets/module-exports-putter.cjs index 9bef17b90e1a77..7afb1e3aa61fca 100644 --- a/bench/snippets/module-exports-putter.cjs +++ b/bench/snippets/module-exports-putter.cjs @@ -1,6 +1,6 @@ // This is a stress test of some internals in How Bun does the module.exports assignment. // If it crashes or throws then this fails -import("./runner.mjs").then(({ bench, run }) => { +import("../runner.mjs").then(({ bench, run }) => { bench("Object.defineProperty(module, 'exports', { get() { return 42; } })", () => { Object.defineProperty(module, "exports", { get() { @@ -36,7 +36,9 @@ import("./runner.mjs").then(({ bench, run }) => { a: 1, }; - console.log( + const log = !process?.env?.BENCHMARK_RUNNER ? console.log : () => {}; + + log( module?.exports, require.cache[module.id].exports, module?.exports === require.cache[module.id], @@ -49,10 +51,11 @@ import("./runner.mjs").then(({ bench, run }) => { return 42; }; - console.log(module.exports, module.exports()); + log(module.exports); + log(module.exports, module.exports()); queueMicrotask(() => { - console.log( + log( module?.exports, require.cache[module.id].exports, module?.exports === require.cache[module.id]?.exports, diff --git a/bench/snippets/native-overhead.mjs b/bench/snippets/native-overhead.mjs index 2c33c46fab5307..32d459247e26e5 100644 --- a/bench/snippets/native-overhead.mjs +++ b/bench/snippets/native-overhead.mjs @@ -1,4 +1,4 @@ -import { bench, run } from "./runner.mjs"; +import { bench, run } from "../runner.mjs"; // These are no-op C++ functions that are exported to JS. const lazy = globalThis[Symbol.for("Bun.lazy")]; diff --git a/bench/snippets/new-incomingmessage.mjs b/bench/snippets/new-incomingmessage.mjs index 2821ee876ae4c3..13cd172646391e 100644 --- a/bench/snippets/new-incomingmessage.mjs +++ b/bench/snippets/new-incomingmessage.mjs @@ -1,5 +1,5 @@ import { IncomingMessage } from "node:http"; -import { bench, run } from "./runner.mjs"; +import { bench, run } from "../runner.mjs"; const headers = { date: "Mon, 06 Nov 2023 05:12:49 GMT", diff --git a/bench/snippets/node-vm.mjs b/bench/snippets/node-vm.mjs index c8c2ac41bb7f04..74bed6a4be3fde 100644 --- a/bench/snippets/node-vm.mjs +++ b/bench/snippets/node-vm.mjs @@ -1,6 +1,6 @@ // @runtime node, bun import * as vm from "node:vm"; -import { bench, run } from "./runner.mjs"; +import { bench, run } from "../runner.mjs"; const context = { animal: "cat", diff --git a/bench/snippets/noop.js b/bench/snippets/noop.js index 9b9f1a1d12dbfa..6b647064c16aa4 100644 --- a/bench/snippets/noop.js +++ b/bench/snippets/noop.js @@ -1,4 +1,4 @@ -import { bench, run } from "./runner.mjs"; +import { bench, run } from "../runner.mjs"; var noop = globalThis[Symbol.for("Bun.lazy")]("noop"); var { function: noopFn, callback } = noop; diff --git a/bench/snippets/object-entries.mjs b/bench/snippets/object-entries.mjs index c3e4bf9e5b5271..8c4b331b51a53e 100644 --- a/bench/snippets/object-entries.mjs +++ b/bench/snippets/object-entries.mjs @@ -1,5 +1,5 @@ // so it can run in environments without node module resolution -import { bench, run } from "../../node_modules/mitata/src/cli.mjs"; +import { bench, run } from "../runner.mjs"; const obj = { a: 1, diff --git a/bench/snippets/object-values.mjs b/bench/snippets/object-values.mjs index 5ca6db473ba958..86e4bef2c1bb5c 100644 --- a/bench/snippets/object-values.mjs +++ b/bench/snippets/object-values.mjs @@ -24,7 +24,7 @@ const obj = { w: 23, }; -import { bench, run } from "./runner.mjs"; +import { bench, run } from "../runner.mjs"; var val = 0; bench("Object.values(literal)", () => { diff --git a/bench/snippets/path-resolve.mjs b/bench/snippets/path-resolve.mjs index 1e0a40456f6f7d..8263a7b0484f9c 100644 --- a/bench/snippets/path-resolve.mjs +++ b/bench/snippets/path-resolve.mjs @@ -1,5 +1,5 @@ -import { bench, run } from "mitata"; import { posix } from "path"; +import { bench, run } from "../runner.mjs"; const pathConfigurations = [ "", diff --git a/bench/snippets/pbkdf2.mjs b/bench/snippets/pbkdf2.mjs index a4f6ac8b58f9dd..3b286543ecccbc 100644 --- a/bench/snippets/pbkdf2.mjs +++ b/bench/snippets/pbkdf2.mjs @@ -1,6 +1,6 @@ import { pbkdf2 } from "node:crypto"; -import { bench, run } from "./runner.mjs"; +import { bench, run } from "../runner.mjs"; const password = "password"; const salt = "salt"; diff --git a/bench/snippets/peek-promise.mjs b/bench/snippets/peek-promise.mjs index f883d4d4c5b685..9468efca25a1fe 100644 --- a/bench/snippets/peek-promise.mjs +++ b/bench/snippets/peek-promise.mjs @@ -1,5 +1,5 @@ import { peek } from "bun"; -import { bench, run } from "mitata"; +import { bench, run } from "../runner.mjs"; let pending = Bun.sleep(1000); let resolved = Promise.resolve(1); diff --git a/bench/snippets/performance-now-overhead.js b/bench/snippets/performance-now-overhead.js index b5283b6ff230fc..b7626e3312d16c 100644 --- a/bench/snippets/performance-now-overhead.js +++ b/bench/snippets/performance-now-overhead.js @@ -1,4 +1,4 @@ -import { bench, run } from "./runner.mjs"; +import { bench, run } from "../runner.mjs"; bench("performance.now x 1000", () => { for (let i = 0; i < 1000; i++) { performance.now(); diff --git a/bench/snippets/private.mjs b/bench/snippets/private.mjs index 452dab06b74260..2cf72a3ced6072 100644 --- a/bench/snippets/private.mjs +++ b/bench/snippets/private.mjs @@ -1,4 +1,4 @@ -import { bench, run } from "../node_modules/mitata/src/cli.mjs"; +import { bench, run } from "../runner.mjs"; // This is a benchmark of the performance impact of using private properties. bench("Polyfillprivate", () => { diff --git a/bench/snippets/process-cwd.mjs b/bench/snippets/process-cwd.mjs index 28df045acb2cce..9d7576e2539e89 100644 --- a/bench/snippets/process-cwd.mjs +++ b/bench/snippets/process-cwd.mjs @@ -1,4 +1,4 @@ -import { bench, run } from "mitata"; +import { bench, run } from "../runner.mjs"; bench("process.cwd()", () => { process.cwd(); diff --git a/bench/snippets/process-info.mjs b/bench/snippets/process-info.mjs index 13e54e50e79546..bb053a205f0667 100644 --- a/bench/snippets/process-info.mjs +++ b/bench/snippets/process-info.mjs @@ -1,5 +1,5 @@ import { performance } from "perf_hooks"; -import { bench, run } from "./runner.mjs"; +import { bench, run } from "../runner.mjs"; bench("process.memoryUsage()", () => { process.memoryUsage(); diff --git a/bench/snippets/process.mjs b/bench/snippets/process.mjs index 40bb48e0e1b44d..666fc8dcaf7e25 100644 --- a/bench/snippets/process.mjs +++ b/bench/snippets/process.mjs @@ -1,4 +1,4 @@ -import { bench, run } from "./runner.mjs"; +import { bench, run } from "../runner.mjs"; bench("process.stderr.write('hey')", () => { process.stderr.write("hey"); diff --git a/bench/snippets/react-dom-render.bun.js b/bench/snippets/react-dom-render.bun.js index 11485b021e3f81..d808b9547f114b 100644 --- a/bench/snippets/react-dom-render.bun.js +++ b/bench/snippets/react-dom-render.bun.js @@ -1,6 +1,6 @@ import { renderToReadableStream as renderToReadableStreamBun } from "react-dom/server"; import { renderToReadableStream } from "react-dom/server.browser"; -import { bench, group, run } from "./runner.mjs"; +import { bench, group, run } from "../runner.mjs"; const App = () => (
diff --git a/bench/snippets/read-file-chunk.mjs b/bench/snippets/read-file-chunk.mjs index fafdd76b411a7e..7a0526e1f18ac8 100644 --- a/bench/snippets/read-file-chunk.mjs +++ b/bench/snippets/read-file-chunk.mjs @@ -1,7 +1,7 @@ import { createReadStream, writeFileSync } from "node:fs"; import { tmpdir } from "node:os"; import { sep } from "node:path"; -import { bench, run } from "./runner.mjs"; +import { bench, run } from "../runner.mjs"; if (!Promise.withResolvers) { Promise.withResolvers = function () { diff --git a/bench/snippets/read-file.mjs b/bench/snippets/read-file.mjs index b808dee792116f..8a9e1f1825a12d 100644 --- a/bench/snippets/read-file.mjs +++ b/bench/snippets/read-file.mjs @@ -1,5 +1,5 @@ import { readFileSync, writeFileSync } from "node:fs"; -import { bench, run } from "./runner.mjs"; +import { bench, run } from "../runner.mjs"; var short = (function () { const text = "Hello World!"; diff --git a/bench/snippets/readdir.mjs b/bench/snippets/readdir.mjs index 4afd214438bdbc..7a43cc6fdcf13f 100644 --- a/bench/snippets/readdir.mjs +++ b/bench/snippets/readdir.mjs @@ -4,7 +4,7 @@ import { readdir } from "fs/promises"; import { relative, resolve } from "path"; import { argv } from "process"; import { fileURLToPath } from "url"; -import { bench, run } from "./runner.mjs"; +import { bench, run } from "../runner.mjs"; let dir = resolve(argv.length > 2 ? argv[2] : fileURLToPath(new URL("../../node_modules", import.meta.url))); if (dir.includes(process.cwd())) { @@ -43,8 +43,11 @@ bench(`await readdir("${dir}", {recursive: false})`, async () => { }); await run(); -console.log("\n", count, "files/dirs in", dir, "\n", "SHA256:", hash, "\n"); -if (count !== syncCount) { - throw new Error(`Mismatched file counts: ${count} async !== ${syncCount} sync`); +if (!process?.env?.BENCHMARK_RUNNER) { + console.log("\n", count, "files/dirs in", dir, "\n", "SHA256:", hash, "\n"); + + if (count !== syncCount) { + throw new Error(`Mismatched file counts: ${count} async !== ${syncCount} sync`); + } } diff --git a/bench/snippets/readfile-not-found.mjs b/bench/snippets/readfile-not-found.mjs index 65c3a30e8ccbaf..af90ba1f6b25b0 100644 --- a/bench/snippets/readfile-not-found.mjs +++ b/bench/snippets/readfile-not-found.mjs @@ -1,6 +1,6 @@ import { readFileSync } from "node:fs"; import { readFile } from "node:fs/promises"; -import { bench, run } from "./runner.mjs"; +import { bench, run } from "../runner.mjs"; bench(`readFileSync(/tmp/404-not-found)`, () => { try { diff --git a/bench/snippets/realpath.mjs b/bench/snippets/realpath.mjs index d7fd2ec7a7a557..30f2bf8da04d71 100644 --- a/bench/snippets/realpath.mjs +++ b/bench/snippets/realpath.mjs @@ -1,5 +1,5 @@ import { realpathSync } from "node:fs"; -import { bench, run } from "./runner.mjs"; +import { bench, run } from "../runner.mjs"; const count = parseInt(process.env.ITERATIONS || "1", 10) || 1; const arg = process.argv[process.argv.length - 1]; diff --git a/bench/snippets/request-response-clone.mjs b/bench/snippets/request-response-clone.mjs index 05a98065602ab7..9ba1f25d935bc6 100644 --- a/bench/snippets/request-response-clone.mjs +++ b/bench/snippets/request-response-clone.mjs @@ -1,5 +1,5 @@ // This mostly exists to check for a memory leak in response.clone() -import { bench, run } from "./runner.mjs"; +import { bench, run } from "../runner.mjs"; const req = new Request("http://localhost:3000/"); const resp = await fetch("http://example.com"); diff --git a/bench/snippets/response-arrayBuffer.mjs b/bench/snippets/response-arrayBuffer.mjs index a3b1f0a730d69c..255c46e7d8149f 100644 --- a/bench/snippets/response-arrayBuffer.mjs +++ b/bench/snippets/response-arrayBuffer.mjs @@ -1,6 +1,6 @@ // This snippet mostly exists to reproduce a memory leak // -import { bench, run } from "mitata"; +import { bench, run } from "../runner.mjs"; const obj = { "id": 1296269, diff --git a/bench/snippets/response-json.mjs b/bench/snippets/response-json.mjs index dd28203f0b4e39..2cd20523b6e0af 100644 --- a/bench/snippets/response-json.mjs +++ b/bench/snippets/response-json.mjs @@ -1,5 +1,5 @@ // This snippet mostly exists to reproduce a memory leak -import { bench, run } from "mitata"; +import { bench, run } from "../runner.mjs"; const obj = { "id": 1296269, diff --git a/bench/snippets/return-await.mjs b/bench/snippets/return-await.mjs index 079eb4bdd0e365..4ccdccf5499c01 100644 --- a/bench/snippets/return-await.mjs +++ b/bench/snippets/return-await.mjs @@ -1,4 +1,4 @@ -import { bench, run } from "../node_modules/mitata/src/cli.mjs"; +import { bench, run } from "../runner.mjs"; bench("return await Promise.resolve(1)", async function () { return await Promise.resolve(1); diff --git a/bench/snippets/rewriter.mjs b/bench/snippets/rewriter.mjs index abdc7f0af5bf8d..4cb1143aac679e 100644 --- a/bench/snippets/rewriter.mjs +++ b/bench/snippets/rewriter.mjs @@ -1,4 +1,4 @@ -import { bench, run } from "./runner.mjs"; +import { bench, run } from "../runner.mjs"; const blob = new Blob(["

Hello

"]); bench("prepend", async () => { diff --git a/bench/snippets/runner.mjs b/bench/snippets/runner.mjs deleted file mode 100644 index 1b985c716b14d1..00000000000000 --- a/bench/snippets/runner.mjs +++ /dev/null @@ -1,22 +0,0 @@ -import process from "node:process"; -import * as Mitata from "../node_modules/mitata/src/cli.mjs"; - -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); -} diff --git a/bench/snippets/semver.mjs b/bench/snippets/semver.mjs index bacacef214ffab..7b3d599a5820c4 100644 --- a/bench/snippets/semver.mjs +++ b/bench/snippets/semver.mjs @@ -1,5 +1,5 @@ import { satisfies } from "semver"; -import { bench, run } from "./runner.mjs"; +import { bench, run } from "../runner.mjs"; const tests = [ ["~1.2.3", "1.2.3", true], ["~1.2", "1.2.0", true], diff --git a/bench/snippets/serialize.mjs b/bench/snippets/serialize.mjs index acd21c5c6c4e5b..80da320dfbd2b3 100644 --- a/bench/snippets/serialize.mjs +++ b/bench/snippets/serialize.mjs @@ -1,5 +1,5 @@ import { deserialize, serialize } from "node:v8"; -import { bench, run } from "./runner.mjs"; +import { bench, run } from "../runner.mjs"; const obj = { "id": 1296269, "node_id": "MDEwOlJlcG9zaXRvcnkxMjk2MjY5", diff --git a/bench/snippets/sha512.js b/bench/snippets/sha512.js index 9b3dcdd7a54942..548bbc096b7df9 100644 --- a/bench/snippets/sha512.js +++ b/bench/snippets/sha512.js @@ -1,5 +1,5 @@ import { SHA512 } from "bun"; -import { bench, run } from "./runner.mjs"; +import { bench, run } from "../runner.mjs"; bench('SHA512.hash("hello world")', () => { SHA512.hash("hello world"); diff --git a/bench/snippets/sha512.node.mjs b/bench/snippets/sha512.node.mjs index e373c4cb3697af..26268ea0ab3543 100644 --- a/bench/snippets/sha512.node.mjs +++ b/bench/snippets/sha512.node.mjs @@ -1,5 +1,5 @@ import { createHash } from "crypto"; -import { bench, run } from "./runner.mjs"; +import { bench, run } from "../runner.mjs"; bench('createHash("sha256").update("hello world").digest()', () => { createHash("sha256").update("hello world").digest(); diff --git a/bench/snippets/shell-spawn.mjs b/bench/snippets/shell-spawn.mjs index eab129eae97235..c3aaf557db80d0 100644 --- a/bench/snippets/shell-spawn.mjs +++ b/bench/snippets/shell-spawn.mjs @@ -1,6 +1,6 @@ import { $ as execa$ } from "execa"; import { $ as zx } from "zx"; -import { bench, group, run } from "./runner.mjs"; +import { bench, group, run } from "../runner.mjs"; const execa = execa$({ stdio: "ignore", cwd: import.meta.dirname }); diff --git a/bench/snippets/spawn-hugemem.mjs b/bench/snippets/spawn-hugemem.mjs index 177382c7439d0a..792381ab0dfece 100644 --- a/bench/snippets/spawn-hugemem.mjs +++ b/bench/snippets/spawn-hugemem.mjs @@ -1,5 +1,5 @@ import { spawnSync } from "bun"; -import { bench, run } from "./runner.mjs"; +import { bench, run } from "../runner.mjs"; var memory = new Uint8Array(128 * 1024 * 1024); memory.fill(10); diff --git a/bench/snippets/spawn-hugemem.node.mjs b/bench/snippets/spawn-hugemem.node.mjs index d33a5d4bd4c7a7..489c1c33e9bbb1 100644 --- a/bench/snippets/spawn-hugemem.node.mjs +++ b/bench/snippets/spawn-hugemem.node.mjs @@ -1,5 +1,5 @@ import { spawnSync } from "child_process"; -import { bench, run } from "./runner.mjs"; +import { bench, run } from "../runner.mjs"; var memory = new Uint8Array(128 * 1024 * 1024); memory.fill(10); diff --git a/bench/snippets/spawn.deno.mjs b/bench/snippets/spawn.deno.mjs index 0e96d9e93e6942..198d3d43ce6f23 100644 --- a/bench/snippets/spawn.deno.mjs +++ b/bench/snippets/spawn.deno.mjs @@ -1,4 +1,4 @@ -import { bench, run } from "../node_modules/mitata/src/cli.mjs"; +import { bench, run } from "../runner.mjs"; bench("spawnSync echo hi", () => { Deno.spawnSync("echo", { diff --git a/bench/snippets/spawn.mjs b/bench/snippets/spawn.mjs index 9c259b096f20b6..8836f19aabbaa9 100644 --- a/bench/snippets/spawn.mjs +++ b/bench/snippets/spawn.mjs @@ -1,5 +1,5 @@ import { spawnSync } from "bun"; -import { bench, run } from "./runner.mjs"; +import { bench, run } from "../runner.mjs"; bench("spawnSync echo hi", () => { spawnSync({ cmd: ["echo", "hi"] }); diff --git a/bench/snippets/spawn.node.mjs b/bench/snippets/spawn.node.mjs index c72a3bf03656bf..008949d9909a6f 100644 --- a/bench/snippets/spawn.node.mjs +++ b/bench/snippets/spawn.node.mjs @@ -1,6 +1,6 @@ // @runtime bun,node,deno import { spawnSync } from "node:child_process"; -import { bench, run } from "./runner.mjs"; +import { bench, run } from "../runner.mjs"; bench("spawnSync echo hi", () => { spawnSync("echo", ["hi"], { encoding: "buffer", shell: false }); diff --git a/bench/snippets/stat.mjs b/bench/snippets/stat.mjs index f39840123f4103..68fd1f5135e183 100644 --- a/bench/snippets/stat.mjs +++ b/bench/snippets/stat.mjs @@ -1,6 +1,6 @@ import { statSync } from "fs"; import { argv } from "process"; -import { bench, run } from "./runner.mjs"; +import { bench, run } from "../runner.mjs"; const dir = argv.length > 2 ? argv[2] : "/tmp"; diff --git a/bench/snippets/stderr.mjs b/bench/snippets/stderr.mjs index 1c348a3f463754..e06c3885889426 100644 --- a/bench/snippets/stderr.mjs +++ b/bench/snippets/stderr.mjs @@ -1,4 +1,4 @@ -import { bench, run } from "./runner.mjs"; +import { bench, run } from "../runner.mjs"; var writer = globalThis.Bun ? Bun.stderr.writer() : undefined; if (writer) diff --git a/bench/snippets/string-decoder.mjs b/bench/snippets/string-decoder.mjs index 950bce9c569f7d..1969937441f3cf 100644 --- a/bench/snippets/string-decoder.mjs +++ b/bench/snippets/string-decoder.mjs @@ -1,5 +1,5 @@ import { StringDecoder } from "string_decoder"; -import { bench, run } from "./runner.mjs"; +import { bench, run } from "../runner.mjs"; var short = Buffer.from("Hello World!"); var shortUTF16 = Buffer.from("Hello World 💕💕💕"); diff --git a/bench/snippets/string-width.mjs b/bench/snippets/string-width.mjs index d37046f832c5a0..d75507657a6609 100644 --- a/bench/snippets/string-width.mjs +++ b/bench/snippets/string-width.mjs @@ -1,5 +1,5 @@ import npmStringWidth from "string-width"; -import { bench, run } from "./runner.mjs"; +import { bench, run } from "../runner.mjs"; const bunStringWidth = globalThis?.Bun?.stringWidth; diff --git a/bench/snippets/structuredClone.mjs b/bench/snippets/structuredClone.mjs index 3007b22f56d47b..684acd3b19fa56 100644 --- a/bench/snippets/structuredClone.mjs +++ b/bench/snippets/structuredClone.mjs @@ -31,7 +31,7 @@ var testArray = [ }, ]; -import { bench, run } from "./runner.mjs"; +import { bench, run } from "../runner.mjs"; bench("structuredClone(array)", () => structuredClone(testArray)); bench("structuredClone(123)", () => structuredClone(123)); diff --git a/bench/snippets/text-decoder-stream.mjs b/bench/snippets/text-decoder-stream.mjs index 5495fdc09b3bf5..c30e45f1b59eeb 100644 --- a/bench/snippets/text-decoder-stream.mjs +++ b/bench/snippets/text-decoder-stream.mjs @@ -1,4 +1,4 @@ -import { bench, run } from "./runner.mjs"; +import { bench, run } from "../runner.mjs"; const latin1 = `hello hello hello!!!! `.repeat(10240); diff --git a/bench/snippets/text-decoder.mjs b/bench/snippets/text-decoder.mjs index 340815e9df5b7b..5bf0e90cbfbedd 100644 --- a/bench/snippets/text-decoder.mjs +++ b/bench/snippets/text-decoder.mjs @@ -1,4 +1,4 @@ -import { bench, run } from "../node_modules/mitata/src/cli.mjs"; +import { bench, run } from "../runner.mjs"; var short = new TextEncoder().encode("Hello World!"); var shortUTF16 = new TextEncoder().encode("Hello World 💕💕💕"); diff --git a/bench/snippets/text-encoder-stream.mjs b/bench/snippets/text-encoder-stream.mjs index 788e3fb50b8bd1..ee83f90d5c728b 100644 --- a/bench/snippets/text-encoder-stream.mjs +++ b/bench/snippets/text-encoder-stream.mjs @@ -1,4 +1,4 @@ -import { bench, run } from "./runner.mjs"; +import { bench, run } from "../runner.mjs"; const latin1 = `hello hello hello!!!! `.repeat(10240); diff --git a/bench/snippets/text-encoder.mjs b/bench/snippets/text-encoder.mjs index d0f5c40a4da989..674345177d31b1 100644 --- a/bench/snippets/text-encoder.mjs +++ b/bench/snippets/text-encoder.mjs @@ -1,4 +1,4 @@ -import { bench, run } from "./runner.mjs"; +import { bench, run } from "../runner.mjs"; var short = "Hello World!"; var shortUTF16 = "Hello World 💕💕💕"; diff --git a/bench/snippets/transpiler-2.mjs b/bench/snippets/transpiler-2.mjs index 702fda9d188e52..fdf3deb713d1a7 100644 --- a/bench/snippets/transpiler-2.mjs +++ b/bench/snippets/transpiler-2.mjs @@ -1,5 +1,5 @@ -import { bench, run } from "mitata"; import { join } from "path"; +import { bench, run } from "../runner.mjs"; const code = require("fs").readFileSync( process.argv[2] || join(import.meta.dir, "../node_modules/@babel/standalone/babel.min.js"), diff --git a/bench/snippets/transpiler.mjs b/bench/snippets/transpiler.mjs index 54234160677203..f453270435bf6a 100644 --- a/bench/snippets/transpiler.mjs +++ b/bench/snippets/transpiler.mjs @@ -2,7 +2,7 @@ import { readFileSync } from "fs"; import { createRequire } from "module"; import { dirname } from "path"; import { fileURLToPath } from "url"; -import { bench, group, run } from "./runner.mjs"; +import { bench, group, run } from "../runner.mjs"; const require = createRequire(import.meta.url); const esbuild_ = require("esbuild/lib/main"); const swc_ = require("@swc/core"); diff --git a/bench/snippets/url.mjs b/bench/snippets/url.mjs index 1cb6e7a8f1ea5c..d794b7f6d68dbc 100644 --- a/bench/snippets/url.mjs +++ b/bench/snippets/url.mjs @@ -1,4 +1,4 @@ -import { bench, run } from "./runner.mjs"; +import { bench, run } from "../runner.mjs"; bench(`new URL('https://example.com/')`, () => { const url = new URL("https://example.com/"); diff --git a/bench/snippets/urlsearchparams.mjs b/bench/snippets/urlsearchparams.mjs index af653c917fedc7..83a874dc5f191a 100644 --- a/bench/snippets/urlsearchparams.mjs +++ b/bench/snippets/urlsearchparams.mjs @@ -1,4 +1,4 @@ -import { bench, run } from "./runner.mjs"; +import { bench, run } from "../runner.mjs"; // bench("new URLSearchParams({})", () => { // return new URLSearchParams({}); diff --git a/bench/snippets/util-deprecate.mjs b/bench/snippets/util-deprecate.mjs index 364601d79a4804..1acd31f5a18e99 100644 --- a/bench/snippets/util-deprecate.mjs +++ b/bench/snippets/util-deprecate.mjs @@ -1,4 +1,4 @@ -import { bench, run } from "./runner.mjs"; +import { bench, run } from "../runner.mjs"; function deprecateUsingClosure(fn, msg, code) { if (process.noDeprecation === true) { return fn; diff --git a/bench/snippets/webcrypto.mjs b/bench/snippets/webcrypto.mjs index 2d1256cf8fd28a..2ae35652d7253f 100644 --- a/bench/snippets/webcrypto.mjs +++ b/bench/snippets/webcrypto.mjs @@ -1,5 +1,4 @@ -import { group } from "mitata"; -import { bench, run } from "./runner.mjs"; +import { bench, group, run } from "../runner.mjs"; const sizes = [ ["small (63 bytes)", 63], @@ -10,7 +9,7 @@ for (let [name, size] of sizes) { group(name, () => { var buf = new Uint8Array(size); for (let algorithm of ["SHA-1", "SHA-256", "SHA-384", "SHA-512"]) { - bench(algorithm, async () => { + bench(`${algorithm} (${name})`, async () => { await crypto.subtle.digest(algorithm, buf); }); } diff --git a/bench/snippets/write-file-huge.mjs b/bench/snippets/write-file-huge.mjs index fe874c9399077f..f79a8ca991801c 100644 --- a/bench/snippets/write-file-huge.mjs +++ b/bench/snippets/write-file-huge.mjs @@ -1,6 +1,6 @@ import { Buffer } from "node:buffer"; import { writeFile } from "node:fs/promises"; -import { bench, run } from "./runner.mjs"; +import { bench, run } from "../runner.mjs"; var hugeFile = Buffer.alloc(1024 * 1024 * 64); var medFile = Buffer.alloc(1024 * 1024 * 16); diff --git a/bench/snippets/write-file.mjs b/bench/snippets/write-file.mjs index 1b054c4daa33ee..e16732cb7e3c74 100644 --- a/bench/snippets/write-file.mjs +++ b/bench/snippets/write-file.mjs @@ -1,5 +1,5 @@ import { writeFileSync } from "node:fs"; -import { bench, run } from "./runner.mjs"; +import { bench, run } from "../runner.mjs"; var short = "Hello World!"; var shortUTF16 = "Hello World 💕💕💕"; diff --git a/bench/snippets/write.bun.js b/bench/snippets/write.bun.js index 0a747bf9587264..a3ea86b871278c 100644 --- a/bench/snippets/write.bun.js +++ b/bench/snippets/write.bun.js @@ -1,6 +1,6 @@ import { write } from "bun"; import { openSync } from "fs"; -import { bench, run } from "./runner.mjs"; +import { bench, run } from "../runner.mjs"; bench('write(/tmp/foo.txt, "short string")', async () => { await write("/tmp/foo.txt", "short string"); diff --git a/bench/snippets/write.node.mjs b/bench/snippets/write.node.mjs index 823648a50bebf8..92b97f77c865ab 100644 --- a/bench/snippets/write.node.mjs +++ b/bench/snippets/write.node.mjs @@ -2,7 +2,7 @@ import { Buffer } from "node:buffer"; import { openSync, writeSync as write } from "node:fs"; import { writeFile } from "node:fs/promises"; -import { bench, run } from "./runner.mjs"; +import { bench, run } from "../runner.mjs"; bench("writeFile(/tmp/foo.txt, short string)", async () => { await writeFile("/tmp/foo.txt", "short string", "utf8"); diff --git a/bench/sqlite/better-sqlite3.mjs b/bench/sqlite/better-sqlite3.mjs index 2412d141bd249f..cf32b3e9125604 100644 --- a/bench/sqlite/better-sqlite3.mjs +++ b/bench/sqlite/better-sqlite3.mjs @@ -1,5 +1,5 @@ -import { bench, run } from "mitata"; import { createRequire } from "module"; +import { bench, run } from "../runner.mjs"; const require = createRequire(import.meta.url); const db = require("better-sqlite3")("./src/northwind.sqlite"); diff --git a/bench/sqlite/bun.js b/bench/sqlite/bun.js index 3e0bc417aeef26..9d2167c30bdefd 100644 --- a/bench/sqlite/bun.js +++ b/bench/sqlite/bun.js @@ -1,5 +1,5 @@ import { Database } from "bun:sqlite"; -import { bench, run } from "mitata"; +import { bench, run } from "../runner.mjs"; import { join } from "path"; const db = Database.open(join(import.meta.dir, "src", "northwind.sqlite")); diff --git a/bench/sqlite/deno.js b/bench/sqlite/deno.js index f4e4cc1b3b93ac..74ab5b9ebe09fb 100644 --- a/bench/sqlite/deno.js +++ b/bench/sqlite/deno.js @@ -1,5 +1,5 @@ import { Database } from "https://deno.land/x/sqlite3@0.11.1/mod.ts"; -import { bench, run } from "../node_modules/mitata/src/cli.mjs"; +import { bench, run } from "../runner.mjs"; const db = new Database("./src/northwind.sqlite"); diff --git a/bench/sqlite/node.mjs b/bench/sqlite/node.mjs index 6e2fb2dc9f0677..e620913aaa695a 100644 --- a/bench/sqlite/node.mjs +++ b/bench/sqlite/node.mjs @@ -1,7 +1,7 @@ // Run `node --experimental-sqlite bench/sqlite/node.mjs` to run the script. // You will need `--experimental-sqlite` flag to run this script and node v22.5.0 or higher. -import { bench, run } from "mitata"; import { DatabaseSync as Database } from "node:sqlite"; +import { bench, run } from "../runner.mjs"; const db = new Database("./src/northwind.sqlite");