diff options
Diffstat (limited to 'bench/snippets')
-rw-r--r-- | bench/snippets/array-map.mjs | 42 | ||||
-rw-r--r-- | bench/snippets/assert.mjs | 5 | ||||
-rw-r--r-- | bench/snippets/async-overhead.mjs | 11 | ||||
-rw-r--r-- | bench/snippets/buffer-read.js | 4 | ||||
-rw-r--r-- | bench/snippets/buffer.js | 9 | ||||
-rw-r--r-- | bench/snippets/callbacks-overhead.mjs | 22 | ||||
-rw-r--r-- | bench/snippets/concat.js | 34 | ||||
-rw-r--r-- | bench/snippets/console-log.mjs | 9 | ||||
-rw-r--r-- | bench/snippets/deep-equals.js | 14 | ||||
-rw-r--r-- | bench/snippets/define-properties.mjs | 9 | ||||
-rw-r--r-- | bench/snippets/dns.node.mjs | 14 | ||||
-rw-r--r-- | bench/snippets/dns.ts | 56 | ||||
-rw-r--r-- | bench/snippets/escapeHTML.js | 9 | ||||
-rw-r--r-- | bench/snippets/ffi-overhead.mjs | 31 | ||||
-rw-r--r-- | bench/snippets/index-of.mjs | 2 | ||||
-rw-r--r-- | bench/snippets/package.json | 3 | ||||
-rw-r--r-- | bench/snippets/react-dom-render.bun.js | 56 | ||||
-rw-r--r-- | bench/snippets/return-await.mjs | 1 | ||||
-rw-r--r-- | bench/snippets/transpiler.mjs | 6 |
19 files changed, 99 insertions, 238 deletions
diff --git a/bench/snippets/array-map.mjs b/bench/snippets/array-map.mjs index 2b6f4f669..615770220 100644 --- a/bench/snippets/array-map.mjs +++ b/bench/snippets/array-map.mjs @@ -1,7 +1,7 @@ // https://github.com/oven-sh/bun/issues/1096 import { bench, run } from "mitata"; -const identity = (x) => x; +const identity = x => x; for (let i = 0; i < 20; i++) { var array = new Array(i); @@ -22,35 +22,15 @@ bench("inline Array.map x 6", () => [1, 1, 1, 1, 1, 1].map(identity)); bench("inline Array.map x 7", () => [1, 1, 1, 1, 1, 1, 1].map(identity)); bench("inline Array.map x 8", () => [1, 1, 1, 1, 1, 1, 1, 1].map(identity)); bench("inline Array.map x 9", () => [1, 1, 1, 1, 1, 1, 1, 1, 1].map(identity)); -bench("inline Array.map x 10", () => - [1, 1, 1, 1, 1, 1, 1, 1, 1, 1].map(identity) -); -bench("inline Array.map x 11", () => - [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1].map(identity) -); -bench("inline Array.map x 12", () => - [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1].map(identity) -); -bench("inline Array.map x 13", () => - [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1].map(identity) -); -bench("inline Array.map x 14", () => - [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1].map(identity) -); -bench("inline Array.map x 15", () => - [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1].map(identity) -); -bench("inline Array.map x 16", () => - [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1].map(identity) -); -bench("inline Array.map x 17", () => - [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1].map(identity) -); -bench("inline Array.map x 18", () => - [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1].map(identity) -); -bench("inline Array.map x 19", () => - [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1].map(identity) -); +bench("inline Array.map x 10", () => [1, 1, 1, 1, 1, 1, 1, 1, 1, 1].map(identity)); +bench("inline Array.map x 11", () => [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1].map(identity)); +bench("inline Array.map x 12", () => [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1].map(identity)); +bench("inline Array.map x 13", () => [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1].map(identity)); +bench("inline Array.map x 14", () => [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1].map(identity)); +bench("inline Array.map x 15", () => [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1].map(identity)); +bench("inline Array.map x 16", () => [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1].map(identity)); +bench("inline Array.map x 17", () => [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1].map(identity)); +bench("inline Array.map x 18", () => [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1].map(identity)); +bench("inline Array.map x 19", () => [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1].map(identity)); await run(); diff --git a/bench/snippets/assert.mjs b/bench/snippets/assert.mjs index bbc36d1ea..dc6c98d2e 100644 --- a/bench/snippets/assert.mjs +++ b/bench/snippets/assert.mjs @@ -6,10 +6,7 @@ bench("deepEqual", () => { }); bench("deepStrictEqual", () => { - assert.deepStrictEqual( - { foo: "123", beep: "boop" }, - { foo: "123", beep: "boop" }, - ); + assert.deepStrictEqual({ foo: "123", beep: "boop" }, { foo: "123", beep: "boop" }); }); await run(); diff --git a/bench/snippets/async-overhead.mjs b/bench/snippets/async-overhead.mjs index bec278b56..753af1632 100644 --- a/bench/snippets/async-overhead.mjs +++ b/bench/snippets/async-overhead.mjs @@ -19,13 +19,10 @@ bench("promise.nextTick", async function () { }); bench("await new Promise(resolve => resolve())", async function () { - await new Promise((resolve) => resolve()); + await new Promise(resolve => resolve()); +}); +bench("Promise.all(Array.from({length: 100}, () => new Promise((resolve) => resolve())))", async function () { + return Promise.all(Array.from({ length: 100 }, () => Promise.resolve(1))); }); -bench( - "Promise.all(Array.from({length: 100}, () => new Promise((resolve) => resolve())))", - async function () { - return Promise.all(Array.from({ length: 100 }, () => Promise.resolve(1))); - }, -); await run(); diff --git a/bench/snippets/buffer-read.js b/bench/snippets/buffer-read.js index 5da645153..46c64b59f 100644 --- a/bench/snippets/buffer-read.js +++ b/bench/snippets/buffer-read.js @@ -23,9 +23,7 @@ time("Uint8Array[]", () => array[0]); console.log(""); time("Buffer.getBigInt64BE ", () => buf.readBigInt64BE(0)); -time("DataView.getBigInt64 (BE)", () => - view.getBigInt64(0, false).toString(10) -); +time("DataView.getBigInt64 (BE)", () => view.getBigInt64(0, false).toString(10)); console.log(""); time("Buffer.readBigInt64LE ", () => buf.readBigInt64LE(0)); diff --git a/bench/snippets/buffer.js b/bench/snippets/buffer.js index 9ababbf35..22dad8e34 100644 --- a/bench/snippets/buffer.js +++ b/bench/snippets/buffer.js @@ -10,18 +10,13 @@ var time = (name, fn) => { console.timeEnd(name.padEnd('Buffer.write(string, "latin1")'.length)); }; -console.log( - `Run ${new Intl.NumberFormat().format(INTERVAL)} times with a warmup:`, - "\n" -); +console.log(`Run ${new Intl.NumberFormat().format(INTERVAL)} times with a warmup:`, "\n"); const stringToWrite = "hellooooohellooooo"; time('Buffer.write(string, "utf8")', () => buf.write(stringToWrite, "utf8")); time('Buffer.write(string, "ascii")', () => buf.write(stringToWrite, "ascii")); -time('Buffer.write(string, "latin1")', () => - buf.write(stringToWrite, "latin1") -); +time('Buffer.write(string, "latin1")', () => buf.write(stringToWrite, "latin1")); time("Buffer.readBigInt64BE ", () => buf.readBigInt64BE(0)); // time("DataView.getBigInt64 (BE)", () => view.getBigInt64(0, false)); // console.log(""); diff --git a/bench/snippets/callbacks-overhead.mjs b/bench/snippets/callbacks-overhead.mjs index 65171145c..4bc535ecd 100644 --- a/bench/snippets/callbacks-overhead.mjs +++ b/bench/snippets/callbacks-overhead.mjs @@ -35,40 +35,26 @@ async function test(log) { { const a = performance.now(); await tests.async(0); - if (log) - console.log( - `async/await: ${(report.async = (performance.now() - a).toFixed(4))}ms` - ); + if (log) console.log(`async/await: ${(report.async = (performance.now() - a).toFixed(4))}ms`); } { const a = performance.now(); tests.callback(0, function () { - if (log) - console.log( - `callback: ${(report.callback = (performance.now() - a).toFixed( - 4 - ))}ms` - ); + if (log) console.log(`callback: ${(report.callback = (performance.now() - a).toFixed(4))}ms`); }); } { const a = performance.now(); await tests.then(0); - if (log) - console.log( - `then: ${(report.then = (performance.now() - a).toFixed(4))}ms` - ); + if (log) console.log(`then: ${(report.then = (performance.now() - a).toFixed(4))}ms`); } { const a = performance.now(); tests.sync(0); - if (log) - console.log( - `sync: ${(report.sync = (performance.now() - a).toFixed(4))}ms` - ); + if (log) console.log(`sync: ${(report.sync = (performance.now() - a).toFixed(4))}ms`); } } diff --git a/bench/snippets/concat.js b/bench/snippets/concat.js index 46c6e0f7d..310e67c37 100644 --- a/bench/snippets/concat.js +++ b/bench/snippets/concat.js @@ -34,33 +34,25 @@ function polyfillUninitialized(chunks) { const chunkGroups = [ [Uint8Array.from([123]), Uint8Array.from([456]), Uint8Array.from([789])], - Array.from(readFileSync(import.meta.path)).map((a) => Uint8Array.from([a])), + Array.from(readFileSync(import.meta.path)).map(a => Uint8Array.from([a])), [readFileSync(import.meta.path)], Array.from({ length: 42 }, () => readFileSync(import.meta.path)), - Array.from({ length: 2 }, () => - new TextEncoder().encode(readFileSync(import.meta.path, "utf8").repeat(100)) - ), + Array.from({ length: 2 }, () => new TextEncoder().encode(readFileSync(import.meta.path, "utf8").repeat(100))), ]; for (const chunks of chunkGroups) { - group( - `${chunks.reduce( - (prev, curr, i, a) => prev + curr.byteLength, - 0 - )} bytes for ${chunks.length} chunks`, - () => { - bench("Bun.concatArrayBuffers", () => { - Bun.concatArrayBuffers(chunks); - }); - bench("Uint8Array.set", () => { - polyfill(chunks); - }); + group(`${chunks.reduce((prev, curr, i, a) => prev + curr.byteLength, 0)} bytes for ${chunks.length} chunks`, () => { + bench("Bun.concatArrayBuffers", () => { + Bun.concatArrayBuffers(chunks); + }); + bench("Uint8Array.set", () => { + polyfill(chunks); + }); - bench("Uint8Array.set (uninitialized memory)", () => { - polyfillUninitialized(chunks); - }); - } - ); + bench("Uint8Array.set (uninitialized memory)", () => { + polyfillUninitialized(chunks); + }); + }); } await run(); diff --git a/bench/snippets/console-log.mjs b/bench/snippets/console-log.mjs index 9105c71db..b95533f01 100644 --- a/bench/snippets/console-log.mjs +++ b/bench/snippets/console-log.mjs @@ -9,8 +9,7 @@ const json = { url: "https://api.github.com/users/wongmjane", html_url: "https://github.com/wongmjane", followers_url: "https://api.github.com/users/wongmjane/followers", - following_url: - "https://api.github.com/users/wongmjane/following{/other_user}", + following_url: "https://api.github.com/users/wongmjane/following{/other_user}", gists_url: "https://api.github.com/users/wongmjane/gists{/gist_id}", starred_url: "https://api.github.com/users/wongmjane/starred{/owner}{/repo}", subscriptions_url: "https://api.github.com/users/wongmjane/subscriptions", @@ -37,11 +36,7 @@ const json = { }; const inspect = - "Bun" in globalThis - ? Bun.inspect - : "Deno" in globalThis - ? Deno.inspect - : (await import("util")).inspect; + "Bun" in globalThis ? Bun.inspect : "Deno" in globalThis ? Deno.inspect : (await import("util")).inspect; bench("big json object", () => { console.error(json); }); diff --git a/bench/snippets/deep-equals.js b/bench/snippets/deep-equals.js index a56704721..bbb663113 100644 --- a/bench/snippets/deep-equals.js +++ b/bench/snippets/deep-equals.js @@ -259,15 +259,13 @@ const fixture = [ equal: false, }, { - description: - "objects with different `toString` functions returning same values are equal", + description: "objects with different `toString` functions returning same values are equal", value1: { toString: () => "Hello world!" }, value2: { toString: () => "Hello world!" }, equal: true, }, { - description: - "objects with `toString` functions returning different values are not equal", + description: "objects with `toString` functions returning different values are not equal", value1: { toString: () => "Hello world!" }, value2: { toString: () => "Hi!" }, equal: false, @@ -311,13 +309,13 @@ const fixture = [ { description: "equal arrays of objects", value1: [ - ...Array.from({ length: 200000 }, (i) => ({ + ...Array.from({ length: 200000 }, i => ({ a: 1, b: 2, })), ], value2: [ - ...Array.from({ length: 200000 }, (i) => ({ + ...Array.from({ length: 200000 }, i => ({ a: 1, b: 2, })), @@ -495,9 +493,7 @@ for (let { tests, description } of fixture) { bench(equalsFn.name, () => { expected = equalsFn(value1, value2); if (expected !== equal) { - throw new Error( - `Expected ${expected} to be ${equal} for ${description}`, - ); + 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 935737b2d..6a10ab183 100644 --- a/bench/snippets/define-properties.mjs +++ b/bench/snippets/define-properties.mjs @@ -19,14 +19,7 @@ const properties = { writable: { get() { const w = this._writableState; - return ( - !!w && - w.writable !== false && - !w.destroyed && - !w.errored && - !w.ending && - !w.ended - ); + return !!w && w.writable !== false && !w.destroyed && !w.errored && !w.ending && !w.ended; }, set(val) { if (this._writableState) { diff --git a/bench/snippets/dns.node.mjs b/bench/snippets/dns.node.mjs index 1a27afd0d..2796ad702 100644 --- a/bench/snippets/dns.node.mjs +++ b/bench/snippets/dns.node.mjs @@ -7,7 +7,7 @@ bench("(cached) dns.lookup remote x 50", async () => { const total = 50; var remain = total; var done; - await new Promise((resolve) => { + await new Promise(resolve => { for (var i = 0; i < total; i++) run().finally(() => { remain--; @@ -25,7 +25,7 @@ bench("(cached in batch) dns.lookup remote x 50", async () => { const total = 50; var remain = total; var done; - await new Promise((resolve) => { + await new Promise(resolve => { for (var i = 0; i < total; i++) run().finally(() => { remain--; @@ -40,10 +40,9 @@ bench("(cached in batch) dns.lookup remote x 50", async () => { bench("dns.lookup remote x 50", async () => { var remain = 50; var done; - const run = () => - lookup(Math.random().toString() + ".example.com").catch(() => {}); + const run = () => lookup(Math.random().toString() + ".example.com").catch(() => {}); - await new Promise((resolve) => { + await new Promise(resolve => { for (var i = 0; i < 50; i++) run().finally(() => { remain--; @@ -58,10 +57,9 @@ bench("dns.lookup remote x 50", async () => { bench("dns.resolve remote x 50", async () => { var remain = 50; var done; - const run = () => - resolve(Math.random().toString() + ".example.com").catch(() => {}); + const run = () => resolve(Math.random().toString() + ".example.com").catch(() => {}); - await new Promise((resolve) => { + await new Promise(resolve => { for (var i = 0; i < 50; i++) run().finally(() => { remain--; diff --git a/bench/snippets/dns.ts b/bench/snippets/dns.ts index 308d54b6a..930cd3b83 100644 --- a/bench/snippets/dns.ts +++ b/bench/snippets/dns.ts @@ -3,23 +3,16 @@ import { bench, run, group } from "mitata"; async function forEachBackend(name, fn) { group(name, () => { - for (let backend of [ - "libc", - "c-ares", - process.platform === "darwin" ? "system" : "", - ].filter(Boolean)) + for (let backend of ["libc", "c-ares", process.platform === "darwin" ? "system" : ""].filter(Boolean)) bench(backend, fn(backend)); }); } -forEachBackend("dns.lookup remote x 50", (backend) => async () => { - const run = () => - dns - .lookup(Math.random().toString(16) + ".example.com", { backend }) - .catch(() => {}); +forEachBackend("dns.lookup remote x 50", backend => async () => { + const run = () => dns.lookup(Math.random().toString(16) + ".example.com", { backend }).catch(() => {}); var remain = 16; var done; - await new Promise((resolve) => { + await new Promise(resolve => { for (var i = 0; i < 16; i++) run().finally(() => { remain--; @@ -31,7 +24,7 @@ forEachBackend("dns.lookup remote x 50", (backend) => async () => { }); }); -forEachBackend("(cached) dns.lookup remote x 50", (backend) => { +forEachBackend("(cached) dns.lookup remote x 50", backend => { var tld = "example.com"; const run = () => dns.lookup(tld, { backend }).catch(() => {}); @@ -39,7 +32,7 @@ forEachBackend("(cached) dns.lookup remote x 50", (backend) => { const total = 50; var remain = total; var done; - await new Promise((resolve) => { + await new Promise(resolve => { for (var i = 0; i < total; i++) run().finally(() => { remain--; @@ -52,25 +45,22 @@ forEachBackend("(cached) dns.lookup remote x 50", (backend) => { }; }); -forEachBackend( - "(cached in batch) dns.lookup remote x 50", - (backend) => async () => { - var tld = Math.random().toString(16) + ".example.com"; - const run = () => dns.lookup(tld, { backend }).catch(() => {}); - const total = 50; - var remain = total; - var done; - await new Promise((resolve) => { - for (var i = 0; i < total; i++) - run().finally(() => { - remain--; - if (remain === 0) { - done(); - } - }); - done = resolve; - }); - }, -); +forEachBackend("(cached in batch) dns.lookup remote x 50", backend => async () => { + var tld = Math.random().toString(16) + ".example.com"; + const run = () => dns.lookup(tld, { backend }).catch(() => {}); + const total = 50; + var remain = total; + var done; + await new Promise(resolve => { + for (var i = 0; i < total; i++) + run().finally(() => { + remain--; + if (remain === 0) { + done(); + } + }); + done = resolve; + }); +}); await run(); diff --git a/bench/snippets/escapeHTML.js b/bench/snippets/escapeHTML.js index f186b1d2f..19570b9f6 100644 --- a/bench/snippets/escapeHTML.js +++ b/bench/snippets/escapeHTML.js @@ -8,7 +8,7 @@ var bunEscapeHTML = globalThis.escapeHTML || Bun.escapeHTML; const FIXTURE = require("fs") .readFileSync(import.meta.dir + "/_fixture.txt", "utf8") .split("") - .map((a) => { + .map(a => { if (a.charCodeAt(0) > 127) { return "a"; } @@ -16,10 +16,7 @@ const FIXTURE = require("fs") }) .join(""); -const FIXTURE_WITH_UNICODE = require("fs").readFileSync( - import.meta.dir + "/_fixture.txt", - "utf8" -); +const FIXTURE_WITH_UNICODE = require("fs").readFileSync(import.meta.dir + "/_fixture.txt", "utf8"); // from react-dom: const matchHtmlRegExp = /["'&<>]/; @@ -116,7 +113,7 @@ for (let input of [ // bench(`html-entities.encode`, () => htmlEntityEncode(input)); // bench(`he.escape`, () => heEscape(input)); bench(`Bun.escapeHTML`, () => bunEscapeHTML(input)); - } + }, ); } await run(); diff --git a/bench/snippets/ffi-overhead.mjs b/bench/snippets/ffi-overhead.mjs index dcceef7ba..382300ac6 100644 --- a/bench/snippets/ffi-overhead.mjs +++ b/bench/snippets/ffi-overhead.mjs @@ -1,13 +1,4 @@ -import { - viewSource, - dlopen, - CString, - ptr, - toBuffer, - toArrayBuffer, - FFIType, - callback, -} from "bun:ffi"; +import { viewSource, dlopen, CString, ptr, toBuffer, toArrayBuffer, FFIType, callback } from "bun:ffi"; import { bench, group, run } from "mitata"; const types = { @@ -235,9 +226,7 @@ var opened; try { opened = dlopen("/tmp/bun-ffi-test.dylib", types); } catch (e) { - throw new Error( - "Please run `make compile-ffi-test` to compile the ffi test library" - ); + throw new Error("Please run `make compile-ffi-test` to compile the ffi test library"); } const { @@ -403,10 +392,10 @@ group("returns_true", () => { group("return_a_function_ptr_to_function_that_returns_true", () => { bench("return_a_function_ptr_to_function_that_returns_true (raw)", () => - raw_return_a_function_ptr_to_function_that_returns_true() + raw_return_a_function_ptr_to_function_that_returns_true(), ); bench("return_a_function_ptr_to_function_that_returns_true", () => - return_a_function_ptr_to_function_that_returns_true() + return_a_function_ptr_to_function_that_returns_true(), ); }); group("returns_42_float", () => { @@ -427,8 +416,7 @@ group("identity_double", () => { }); var raw_return_a_function_ptr_to_function_that_returns_true = - return_a_function_ptr_to_function_that_returns_true.native ?? - return_a_function_ptr_to_function_that_returns_true; + return_a_function_ptr_to_function_that_returns_true.native ?? return_a_function_ptr_to_function_that_returns_true; var raw_returns_42_float = returns_42_float.native ?? returns_42_float; var raw_returns_42_double = returns_42_double.native ?? returns_42_double; var raw_identity_float = identity_float.native ?? identity_float; @@ -437,14 +425,11 @@ var raw_returns_true = returns_true.native ?? returns_true; var raw_returns_false = returns_false.native ?? returns_false; var raw_returns_42_char = returns_42_char.native ?? returns_42_char; var raw_returns_42_uint8_t = returns_42_uint8_t.native ?? returns_42_uint8_t; -var raw_returns_neg_42_int8_t = - returns_neg_42_int8_t.native ?? returns_neg_42_int8_t; +var raw_returns_neg_42_int8_t = returns_neg_42_int8_t.native ?? returns_neg_42_int8_t; var raw_returns_42_uint16_t = returns_42_uint16_t.native ?? returns_42_uint16_t; var raw_returns_42_uint32_t = returns_42_uint32_t.native ?? returns_42_uint32_t; -var raw_returns_neg_42_int16_t = - returns_neg_42_int16_t.native ?? returns_neg_42_int16_t; -var raw_returns_neg_42_int32_t = - returns_neg_42_int32_t.native ?? returns_neg_42_int32_t; +var raw_returns_neg_42_int16_t = returns_neg_42_int16_t.native ?? returns_neg_42_int16_t; +var raw_returns_neg_42_int32_t = returns_neg_42_int32_t.native ?? returns_neg_42_int32_t; var raw_identity_char = identity_char.native ?? identity_char; var raw_identity_bool = identity_bool.native ?? identity_bool; var raw_identity_bool = identity_bool.native ?? identity_bool; diff --git a/bench/snippets/index-of.mjs b/bench/snippets/index-of.mjs index a7aad7a1e..8f501454d 100644 --- a/bench/snippets/index-of.mjs +++ b/bench/snippets/index-of.mjs @@ -2,7 +2,7 @@ import { bench, run } from "mitata"; 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( - " " + " ", ); bench(`Array.indexOf`, () => { diff --git a/bench/snippets/package.json b/bench/snippets/package.json index b66157182..6244001a8 100644 --- a/bench/snippets/package.json +++ b/bench/snippets/package.json @@ -2,5 +2,6 @@ "dependencies": { "eventemitter3": "^5.0.0", "tiny-typed-emitter": "latest" - } + }, + "prettier": "../../.prettierrc.cjs" } diff --git a/bench/snippets/react-dom-render.bun.js b/bench/snippets/react-dom-render.bun.js index f23848ad8..7b53210e2 100644 --- a/bench/snippets/react-dom-render.bun.js +++ b/bench/snippets/react-dom-render.bun.js @@ -5,64 +5,30 @@ import { renderToReadableStream as renderToReadableStreamBun } from "../test/bun const App = () => ( <div> <h1>Hello, world!</h1> - <p> - This is a React component This is a React component This is a React - component This is a React component. - </p> - <p> - This is a React component This is a React component This is a React - component This is a React component. - </p> - <p> - This is a React component This is a React component This is a React - component This is a React component. - </p> - <p> - This is a React component This is a React component This is a React - component This is a React component. - </p> - <p> - This is a React component This is a React component This is a React - component This is a React component. - </p> + <p>This is a React component This is a React component This is a React component This is a React component.</p> + <p>This is a React component This is a React component This is a React component This is a React component.</p> + <p>This is a React component This is a React component This is a React component This is a React component.</p> + <p>This is a React component This is a React component This is a React component This is a React component.</p> + <p>This is a React component This is a React component This is a React component This is a React component.</p> </div> ); group("new Response(stream).text()", () => { - bench( - "react-dom/server.browser", - async () => await new Response(await renderToReadableStream(<App />)).text() - ); - bench( - "react-dom/server.bun", - async () => - await new Response(await renderToReadableStreamBun(<App />)).text() - ); + bench("react-dom/server.browser", async () => await new Response(await renderToReadableStream(<App />)).text()); + bench("react-dom/server.bun", async () => await new Response(await renderToReadableStreamBun(<App />)).text()); }); group("new Response(stream).arrayBuffer()", () => { bench( "react-dom/server.browser", - async () => - await new Response(await renderToReadableStream(<App />)).arrayBuffer() - ); - bench( - "react-dom/server.bun", - async () => - await new Response(await renderToReadableStreamBun(<App />)).arrayBuffer() + async () => await new Response(await renderToReadableStream(<App />)).arrayBuffer(), ); + bench("react-dom/server.bun", async () => await new Response(await renderToReadableStreamBun(<App />)).arrayBuffer()); }); group("new Response(stream).blob()", () => { - bench( - "react-dom/server.browser", - async () => await new Response(await renderToReadableStream(<App />)).blob() - ); - bench( - "react-dom/server.bun", - async () => - await new Response(await renderToReadableStreamBun(<App />)).blob() - ); + bench("react-dom/server.browser", async () => await new Response(await renderToReadableStream(<App />)).blob()); + bench("react-dom/server.bun", async () => await new Response(await renderToReadableStreamBun(<App />)).blob()); }); await run(); diff --git a/bench/snippets/return-await.mjs b/bench/snippets/return-await.mjs index 1df17a22d..079eb4bdd 100644 --- a/bench/snippets/return-await.mjs +++ b/bench/snippets/return-await.mjs @@ -12,5 +12,4 @@ bench("return await 1", async function () { return await 1; }); - await run(); diff --git a/bench/snippets/transpiler.mjs b/bench/snippets/transpiler.mjs index 2facfeab7..ab4b29dc5 100644 --- a/bench/snippets/transpiler.mjs +++ b/bench/snippets/transpiler.mjs @@ -8,11 +8,7 @@ const esbuild_ = require("esbuild/lib/main"); const swc_ = require("@swc/core"); const babel_ = require("@babel/core"); -const code = readFileSync( - dirname(fileURLToPath(import.meta.url)) + - "/../../src/test/fixtures/simple.jsx", - "utf-8", -); +const code = readFileSync(dirname(fileURLToPath(import.meta.url)) + "/../../src/test/fixtures/simple.jsx", "utf-8"); async function getWithName(name) { let transformSync; |