diff options
| author | 2022-10-18 21:59:47 -0700 | |
|---|---|---|
| committer | 2022-10-18 22:16:51 -0700 | |
| commit | 9c7eb75a9ac845d92bfdfd6cc574dc8f39bde293 (patch) | |
| tree | 57b0e3ba3b6248067f93bcf6a4d25a961bb873e9 /bench/websocket-server/README.md | |
| parent | b0fe1679107541ef5691111f55a7b3db9a81457d (diff) | |
| download | bun-9c7eb75a9ac845d92bfdfd6cc574dc8f39bde293.tar.gz bun-9c7eb75a9ac845d92bfdfd6cc574dc8f39bde293.tar.zst bun-9c7eb75a9ac845d92bfdfd6cc574dc8f39bde293.zip | |
websocker-server
Diffstat (limited to 'bench/websocket-server/README.md')
| -rw-r--r-- | bench/websocket-server/README.md | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/bench/websocket-server/README.md b/bench/websocket-server/README.md new file mode 100644 index 000000000..2578c8d51 --- /dev/null +++ b/bench/websocket-server/README.md @@ -0,0 +1,37 @@ +# websocket-server + +This benchmarks a websocket server intended as a simple but very active chat room. + +First, start the server. By default, it will wait for 16 clients which the client script will handle. + +Run in Bun (`Bun.serve`): + +```bash +bun ./chat-server.bun.js +``` + +Run in Node (`"ws"` package): + +```bash +node ./chat-server.node.mjs +``` + +Run in Deno (`Deno.serve`): + +```bash +deno run -A --unstable ./chat-server.deno.mjs +``` + +Then, run the client script. By default, it will connect 16 clients. This client script can run in Bun, Node, or Deno + +```bash +node ./chat-client.mjs +``` + +The client script loops through a list of messages for each connected client and sends a message. + +For example, when the client sends `"foo"`, the server sends back `"John: foo"` so that all members of the chatroom receive the message. + +The client script waits until it receives all the messages for each client before sending the next batch of messages. + +This project was created using `bun init` in bun v0.2.1. [Bun](https://bun.sh) is a fast all-in-one JavaScript runtime. |
