mirror of
https://github.com/oven-sh/bun
synced 2026-02-10 02:48:50 +00:00
* async all node:fs functions * draw the rest of the owl * LLVM & Clang 16 --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
29 lines
907 B
JavaScript
29 lines
907 B
JavaScript
// @runtime node, bun, deno
|
|
import { bench, run } from "./runner.mjs";
|
|
import { Buffer } from "node:buffer";
|
|
import { openSync } from "node:fs";
|
|
import { writeFile } from "node:fs/promises";
|
|
import { writeSync as write } from "node:fs";
|
|
|
|
bench("writeFile(/tmp/foo.txt, short string)", async () => {
|
|
await writeFile("/tmp/foo.txt", "short string", "utf8");
|
|
});
|
|
|
|
bench("writeFile(/tmp/foo.txt, Buffer.from(short string))", async () => {
|
|
await writeFile("/tmp/foo.txt", Buffer.from("short string"));
|
|
});
|
|
|
|
const fd = openSync("/tmp/foo.txt", "w");
|
|
|
|
bench("write(fd, short string)", () => {
|
|
const bytesWritten = write(fd, "short string", "utf8");
|
|
if (bytesWritten !== 12) throw new Error("wrote !== 12");
|
|
});
|
|
|
|
bench("write(fd, Uint8Array(short string))", () => {
|
|
const bytesWritten = write(fd, Buffer.from("short string"));
|
|
if (bytesWritten !== 12) throw new Error("wrote !== 12");
|
|
});
|
|
|
|
await run();
|