Skip to content

vagnermaltauro/bun-vs-node

Repository files navigation

Bun vs. Node - Performance Comparison

This repository tests memory consumption and performance between Bun and Node.js when running an Express server. Follow the instructions below to set up and run the test.

Prerequisites

Node.js (Node.js Installation)

Bun (Install via the command below)

curl -fsSL https://bun.sh/install | bash

TypeScript (Install globally if needed)

npm install -g typescript

Plow for load testing (Install via cargo)

cargo install plow

Project Setup

Clone the Repository

git clone https://github.com/ThePrimeagen/bun-vs-node.git
cd bun-vs-node

Install Dependencies

Install Dependencies

Compile TypeScript Ensure the TypeScript code is compiled to JavaScript:

npx tsc

Running the Test

The run script starts the server using Bun or Node and monitors memory usage at 1-second intervals.

Make the Script Executable

chmod +x run

Run with Bun

./run bun bun

Run with Node

./run node node

These commands will start the server and track memory usage, saving the results to bun.mem and node.mem, respectively.

Load Testing with Plow

We recommend using plow to perform load tests on the server. For example:

plow http://0.0.0.0:45001 -m POST -c 1000 -n 100000 \
     --body @src/tests/medium.json -T 'application/json' \
     --no-clean -H "x-method: json"
  • -c 1000: Sets 1000 concurrent connections.
  • -n 100000: Sends 100,000 requests.
  • --body @src/tests/medium.json: Sends the contents of the medium.json file as the request body.
  • -T 'application/json': Sets the content type to JSON.
  • -H "x-method: json": Sets the x-method header, necessary to specify the test method.

Analyzing Results

After running the tests, compare the output files (bun.mem and node.mem) to evaluate memory usage for each platform. You can also review the performance metrics generated by plow to assess throughput and latency.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published