aboutsummaryrefslogtreecommitdiff
path: root/bench/snippets/write-file.mjs
blob: 4417c817cd5caefe146edd682929d10c5a5b558d (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
import { readFileSync, writeFileSync } from "node:fs";
import { bench, run } from "./runner.mjs";

var short = "Hello World!";
var shortUTF16 = "Hello World 💕💕💕";
var long = "Hello World!".repeat(1024);
var longUTF16 = "Hello World 💕💕💕".repeat(1024);

bench(`${short.length} ascii`, () => {
  writeFileSync("/tmp/bun.bench-out.txt", short);
});

bench(`${short.length} utf8`, () => {
  writeFileSync("/tmp/bun.bench-out.txt", shortUTF16);
});

bench(`${long.length} ascii`, () => {
  writeFileSync("/tmp/bun.bench-out.txt", long);
});

bench(`${longUTF16.length} utf8`, () => {
  writeFileSync("/tmp/bun.bench-out.txt", longUTF16);
});

await run();