diff options
author | 2023-05-31 19:17:01 -0700 | |
---|---|---|
committer | 2023-05-31 19:17:01 -0700 | |
commit | cb0f76aa73f6b85667b57015a77ac39d9c78aa0b (patch) | |
tree | 949bcc466b3afbbb69a070d35d2b814f0e66be40 /bench/stream-file-upload-client/stream-file-node.mjs | |
parent | 79d7b2075e63f79ec6d1d2a904178969eb701f0b (diff) | |
parent | 110d0752f333e4c32c9226e4a94e93f18837f9c7 (diff) | |
download | bun-cb0f76aa73f6b85667b57015a77ac39d9c78aa0b.tar.gz bun-cb0f76aa73f6b85667b57015a77ac39d9c78aa0b.tar.zst bun-cb0f76aa73f6b85667b57015a77ac39d9c78aa0b.zip |
Merge branch 'main' into jarred/port
Diffstat (limited to 'bench/stream-file-upload-client/stream-file-node.mjs')
-rw-r--r-- | bench/stream-file-upload-client/stream-file-node.mjs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/bench/stream-file-upload-client/stream-file-node.mjs b/bench/stream-file-upload-client/stream-file-node.mjs new file mode 100644 index 000000000..9a0957285 --- /dev/null +++ b/bench/stream-file-upload-client/stream-file-node.mjs @@ -0,0 +1,19 @@ +import { createReadStream } from "node:fs"; +import http from "node:http"; + +console.time("stream-file-node"); +createReadStream(process.env.FILE ?? "hello.txt") + .pipe( + http + .request(process.env.URL ?? "http://localhost:3000", { + method: "POST", + }) + .on("response", response => { + response.on("data", data => { + console.log("Sent", parseInt(data.toString(), 10), "bytes"); + }); + }), + ) + .on("close", () => { + console.timeEnd("stream-file-node"); + }); |