* Add bun-types to packages * Improve typing * Fix types in tests * Fix dts tests * Run formatter * Fix all type errors * Add strict mode, fix type errors * Add ffi changes * Move workflows to root * Add workflows * Remove labeler * Add child_process types * Fix synthetic defaults issue * Remove docs * Move scripts * Run prettier * Include examples in typechecking * captureStackTrace types * moved captureStackTrace types to globals * Address reviews Co-authored-by: Colin McDonnell <colinmcd@alum.mit.edu> Co-authored-by: Dylan Conway <dylan.conway567@gmail.com>
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):
bun ./chat-server.bun.js
Run in Node ("ws" package):
node ./chat-server.node.mjs
Run in Deno (Deno.serve):
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
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.
TODO: once Deno lands their performance improvements, increase the client count (it was originally going to be 32 or 64, but that would've exluded Deno from the benchmark)
This project was created using bun init in bun v0.2.1. Bun is a fast all-in-one JavaScript runtime.