How do you benchmark bun vs node?
Question
How do you benchmark bun vs node?
So far:
git clone https://github.com/samchon/typia.git
cd typia
pnpm i
pnpm run build
cd benchmark
pnpm run build
pnpm run start
pnpm run start:bun
pnpm run start:bun generated some errors, by the way. Does not seem to matter.
Running both of these gives me comparisons to other libs, but not a comparison of bun vs node.
I guess you compare the Megabytes/sec of the two generated README files?
Why are different things tested, btw?
I am making an issue over in the bun repository, and I am pretty sure they are going to ask for results using mitata since that is what they do for all their performance stuff.
That lib kinds looks like jest or testing:
bench("array", () => {
cosineDistance(array1, array2);
});
bench("float32", () => {
cosineDistance(floatArray1, floatArray2);
});
bench("float64", () => {
cosineDistance(floatArray3, floatArray4);
});
await run();
See https://github.com/oven-sh/bun/issues/8079 for an example where i used their benchmarking thing (and now they are looking at it).
So, when i tried that I had a few problems, lots of error about workers??? not sure what workers has to do with typing.
Anyhow, here are the results for a little bit I did:
So, bun is actually twice as fast as node.
test.ts:
import { run, bench } from "mitata";
import typia from "typia";
import { createIsBenchmarkProgram } from "./programs/is/createIsBenchmarkProgram";
import { ArrayRecursive } from "./structures/pure/ArrayRecursive";
import { ArrayRecursiveUnionExplicit } from "./structures/pure/ArrayRecursiveUnionExplicit";
(async function test() {
bench("ArrayRecursiveUnionExplicit", () => {
createIsBenchmarkProgram(typia.createIs<ArrayRecursiveUnionExplicit>());
});
bench("ArrayRecursive", () => {
createIsBenchmarkProgram(typia.createIs<ArrayRecursive>());
});
await run();
})();
4.59/1.75 = Bun is 2.6x times faster than node.
But your benchmarking program is slower on bun, not your typia stuff.
So it would be interesting to see why. Perhaps it has something to do Workers? I know Bun has not declared workers stable yet.
Yes, I compared with two README documents.
Separating each feature as worker, it was suggested by typebox developer @sinclairzx81, to control variable.
If bun's worker is not stable, then we should wait it to be stable.
Is worker stable on bun now?