aboutsummaryrefslogtreecommitdiff
path: root/bench/snippets/crypto-stream.mjs
blob: 3560563d9db8f69f438c7221204609677b16d8ed (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// https://github.com/oven-sh/bun/issues/2190
import { bench, run } from "mitata";
import { createHash } from "node:crypto";

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.";

const scenarios = [
  { alg: "md5", digest: "hex" },
  { alg: "md5", digest: "base64" },
  { alg: "sha1", digest: "hex" },
  { alg: "sha1", digest: "base64" },
  { alg: "sha256", digest: "hex" },
  { alg: "sha256", digest: "base64" },
];

for (const { alg, digest } of scenarios) {
  bench(`${alg}-${digest}`, () => {
    const hasher = createHash(alg);
    hasher.write(data);
    hasher.end();
    hasher.read();
  });
}

run();
retro' width='13' height='13' alt='Gravatar' /> Dylan Conway 1-2/+11 2023-08-31Make breakpoints faster in VSCode extensionGravatar Ashcon Partovi 1-241/+327 2023-08-31`bun install` correctly join dependency URLs (#4421)Gravatar Julian 6-64/+243 2023-08-31get name if not provided in `FormData.append` (#4434)Gravatar Dylan Conway 4-5/+45 2023-08-31Fix vscode debug terminalGravatar Ashcon Partovi 1-21/+0