Giter Club home page Giter Club logo

bun-http-framework-benchmark's Introduction

SaltyAom

I make Open Source and cosplay

Create Elysia, an ergonomic framework for Humans.

SaltyAom's Tingyun cosplay



Speaks at several tech events:

  • BKK.js
  • Dev Mountain Festival
  • Stupid Hackathon

Looking forward to speaks at your events (I can cosplay to speak at your event too)

Stuff I made

  • Elysia: Ergonomic framework for Humans
  • Niku: Effortlessly compose your Flutter UI for humans.
  • Mobius - GraphQL schema to TypeScript without code generation
  • Dorothy: Character AI at home (Repo): Configurable Character AI like using Gemini or GPT or Cloudflare AI interchangeable with low price stack and full type-safety
  • Skooldio's TypeScript Mastery Corse

Random thing I made

Mutsuki

$$\ce{$\unicode[goombafont; z-index: -10; pointer-events: none; position: fixed; top: 0; left: 0; width: 100%; opacity: 0.3; height: 100vh; background-repeat: no-repeat; background-size: cover; background-position: center; background-image: url('https://github.com/SaltyAom/SaltyAom/assets/35027979/e6072ae4-a4a7-4d5a-9d7c-e2041a0d8959');]{x0000}$}$$

bun-http-framework-benchmark's People

Contributors

ajimae avatar aquapi avatar boywithkeyboard avatar coratgerl avatar eckhardt-d avatar herudi avatar imlunahey avatar jkenda avatar kapsonfire-de avatar lowbytefox avatar mimimonads avatar nakrovati avatar nirarad10 avatar saltyaom avatar yusukebe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

bun-http-framework-benchmark's Issues

benchmark is unfair

Hey @SaltyAom!

At first, I'd like to thank you for including my framework, cheetah, in your benchmark. But I noticed that you're on a really old version of it and using (optional!) validation through zod which heavily impacts its performance.

I'll open a PR shortly which should fix this issue.

Elysia

image
Elysia may returns only the text or JSON without the header in the test so it is faster than the Bun and Stric implementation.

Sharing my bench stats. I think Windows might give you a lot of bias

Hi there, just sharing some data for comparison. My results are a bit closer to https://web-frameworks-benchmark.netlify.app/ and from https://fastify.dev/benchmarks/ then yours. I think Windows might be a huge bias.

Intel(R) Core(TM) i7-8565U CPU @ 1.80GHz
Linux Mint 21.2 kernel 5.15.0-82-generic

node v20.3.1
bun 1.0.0

Framework Get (/)
uws (node) 91,005.16
bunNoRouter (bun) 89,925.52
stricjs (bun) 88,766.38
elysia (bun) 86,841.69
hyper-express (node) 84,800.68
vixeny (bun) 84,216.08
hono (bun) 73,614.81
nhttp (bun) 72,285.46
bun-web-standard (bun) 67,617.68
baojs (bun) 56,594.58
vanillaNoRouter (node) 32,236.36
fastify (node) 28,463.80
express (node) 8,376.99

For reference, I added a simpler Bun

const text = 'Hello, Bench!';

export default {
  port: 3000,
  fetch() {
    return new Response(text);
  }
};

and a vanilla http

const http = require('http');

http.createServer((request, response) => {
    response.writeHead(200, {
        'Content-Type': 'text/plain'
    });

    response.write('Hi');
    response.end();
}).listen(3000);

You may close this whenever you wish ;-)

EDIT: my fastify result was wrong, I fixed it

Nest.js header is set to wrong type

Here:

@Header('content-type', 'text/html')

you are trying to set the header Content-Type to text/html

But in benchmark you are expecting it to be text/plain, I think that is the cause why you cannot run tests on Nest.js

if (!index.headers.get('Content-Type')?.includes('text/plain'))

You put nestjs into black list with the reason:

// Not setting content-type header for some reason
'node/nest/index',

Is this supposed to be like this?

invalid tests

  • Kingworld is not responding correctly - neither the body is sent back nor it has the correct header
  • bun.ts is doubling json.stringify FIXED: #5

More complex tests

Maybe write a TODO app for each framework with some authentications.
See how hard it is to write a simple TODO app and compare the performance (signup/login API and rendering)

Easiest way to run a single library?

Trying to get my own library added to this and I'm stuck re-running the whole benchmark each time with all of the other libraries.

Is there a way around this? I feel this there's something super obvious that I've missed. ๐Ÿ˜“

maybe add bigger json payload

I adjusted the body.json payload to a more realistic response from your current api and got the following results:

Framework Average Get (/) Params, query & header Post JSON
elysia (bun) 117,896.473 193,111.12 158,312.35 2,265.95
bun (bun) 104,438.447 178,135.06 132,867.79 2,312.49
fast (deno) 37,122.36 36,738.43 37,126.45 37,502.2

maybe it would make sense to add a little bit bigger json payload because it gives totally different result

More workload for the tests

Can you set the number of requests to a high value like 2 millions and the number of connections to 5000?
Or maybe set the request duration to around 30s on each test.

The JIT takes some time to compile and you should delay the process for around 10s for optimizations to work.

Slight adjustment in requirement for json

Your test is good because the requirements make it impossible to cheat with a simplified parser / hardcoded response. BUT - the requirements for JSON parsing is ambiguous.

If you change the rule from "Server MUST parse body to JSON and serialize back to string" to something like "Server must respond with the value from JSON key "hello", then you have a defined requirement that is never ambiguous in what it means to "parse json".

Because, to parse and serialize JSON is basically "no operation". But taking the "world" from key "hello" makes it defined.

Why is the uws benchmark run only under Node.js and not Bun also?

With the "uws framework (node)" entry always being the top performer, why is it only ever run under Node.js and not re-run under Bun also?

I understand uws is used as the built-in web server of Bun and then also ElysiaJS. But there's no vanilla standalone benchmark run for it using Bun? Is it not possible?

`Wanted size: 80x25` on running baojs

Steps to reproduce

  1. install bun v0.7.2
  2. bun install
  3. bun run benchmark

Output

>>> bun run benchmark                                                                       $ node bench.mjs
30 frameworks
- bun/baojs
- bun/bun
- bun/bun-bakery/index
- bun/bun-web-standard
- bun/elysia
- bun/express
- bun/hono
- bun/hyperbun
- bun/koa
- bun/nbit
- bun/nhttp
- bun/stricjs
- bun/vixeny
- deno/abc
- deno/acorn
- deno/cheetah
- deno/fast
- deno/hono
- deno/oak
- node/adonis/index
- node/elysia
- node/express
- node/fastify
- node/h3
- node/hapi
- node/hono
- node/hyper-express
- node/koa
- node/nest/index
- node/uws

Estimate time: 15:30 min

 baojs
 > bun baojs 

NODE_ENV=production ENV=production bun src/bun/baojs.ts

Current size: 80x24. Wanted size: 80x25.

image

I'm not sure the reason this message is being reported, as my terminal is bigger than 80x24.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.