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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
import { readFileSync, writeFileSync } from "node:fs";
import { bench, run } from "mitata";
var short = (function () {
const text = "Hello World!";
const path = "/tmp/bun-bench-short.text";
writeFileSync(path, text, "utf8");
return { path, length: text.length };
})();
var shortUTF16 = (function () {
const text = "Hello World 💕💕💕";
const path = "/tmp/bun-bench-shortUTF16.text";
writeFileSync(path, text, "utf8");
return { path, length: text.length };
})();
var long = (function () {
const text = "Hello World!".repeat(1024);
const path = "/tmp/bun-bench-long.text";
writeFileSync(path, text, "utf8");
return { path, length: text.length };
})();
var longUTF16 = (function () {
const text = "Hello World 💕💕💕".repeat(1024);
const path = "/tmp/bun-bench-longUTF16.text";
writeFileSync(path, text, "utf8");
return { path, length: text.length };
})();
bench(`${short.length} ascii`, () => {
readFileSync(short.path, "utf-8");
});
bench(`${short.length} utf8`, () => {
readFileSync(shortUTF16.path, "utf-8");
});
bench(`${long.length} ascii`, () => {
readFileSync(long.path, "utf-8");
});
bench(`${longUTF16.length} utf8`, () => {
readFileSync(longUTF16.path, "utf-8");
});
await run();
|