Open huseeiin opened 5 months ago
bun probably has a more expensive default configuration
Including the additional cost factors:
import { group, bench, run } from "mitata";
import { hash, Algorithm } from "@node-rs/argon2";
group("hashers", () => {
bench("Bun.password", async () => {
await Bun.password.hash("hello", {
algorithm: 'argon2id',
memoryCost: 512,
timeCost: 512,
});
});
bench("@node-rs/argon2", async () => {
await hash("hello", {
algorithm: Algorithm.Argon2id,
memoryCost: 512,
timeCost: 512,
});
});
});
await run();
Yields the following:
cpu: Intel(R) Core(TM) i3-4360 CPU @ 3.70GHz
runtime: bun 1.0.25 (x64-linux)
benchmark time (avg) (min … max) p75 p99 p995
------------------------------------------------------- -----------------------------
• hashers
------------------------------------------------------- -----------------------------
Bun.password 175.89 ms/iter (166.86 ms … 195.69 ms) 179.31 ms 195.69 ms 195.69 ms
@node-rs/argon2 127.42 ms/iter (121.01 ms … 135.33 ms) 132.02 ms 135.33 ms 135.33 ms
summary for hashers
@node-rs/argon2
1.38x faster than Bun.password