aboutsummaryrefslogtreecommitdiff
path: root/bench/snippets
diff options
context:
space:
mode:
Diffstat (limited to 'bench/snippets')
-rw-r--r--bench/snippets/cat.bun.js5
-rw-r--r--bench/snippets/cat.mjs1
-rw-r--r--bench/snippets/cat.node.js4
-rw-r--r--bench/snippets/copy.bun.js4
4 files changed, 14 insertions, 0 deletions
diff --git a/bench/snippets/cat.bun.js b/bench/snippets/cat.bun.js
new file mode 100644
index 000000000..1bb1c809a
--- /dev/null
+++ b/bench/snippets/cat.bun.js
@@ -0,0 +1,5 @@
+import { resolve } from "path";
+const { write, stdout, file } = Bun;
+const input = resolve(process.argv[process.argv.length - 1]);
+
+await write(stdout, file(input));
diff --git a/bench/snippets/cat.mjs b/bench/snippets/cat.mjs
index 7e4f3da54..ca6dfe838 100644
--- a/bench/snippets/cat.mjs
+++ b/bench/snippets/cat.mjs
@@ -1,3 +1,4 @@
+// works in both bun & node
import { readFileSync } from "node:fs";
const count = parseInt(process.env.ITERATIONS || "1", 10) || 1;
const arg = process.argv.slice(1);
diff --git a/bench/snippets/cat.node.js b/bench/snippets/cat.node.js
new file mode 100644
index 000000000..d38d7c537
--- /dev/null
+++ b/bench/snippets/cat.node.js
@@ -0,0 +1,4 @@
+const path = require("path");
+const fs = require("fs");
+const input = path.resolve(process.argv[process.argv.length - 1]);
+fs.createReadStream(input).pipe(process.stdout);
diff --git a/bench/snippets/copy.bun.js b/bench/snippets/copy.bun.js
new file mode 100644
index 000000000..20269212a
--- /dev/null
+++ b/bench/snippets/copy.bun.js
@@ -0,0 +1,4 @@
+import path from "path";
+const input = path.resolve(process.argv[process.argv.length - 2]);
+const output = path.resolve(process.argv[process.argv.length - 1]);
+await Bun.write(Bun.file(output), Bun.file(input));