Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hyper-Express + Benzene benchmark #78

Open
dougg0k opened this issue Feb 23, 2022 · 1 comment
Open

Hyper-Express + Benzene benchmark #78

dougg0k opened this issue Feb 23, 2022 · 1 comment

Comments

@dougg0k
Copy link

dougg0k commented Feb 23, 2022

Just tried out what is in the title, gave the best result.

https://github.com/kartikk221/hyper-express

https://github.com/kartikk221/hyper-express/blob/master/docs/Benchmarks.md

Machine: Linux 5.15.25-xanmod1 x86_64 | 16 vCPUs | 32GB
Node: v16.13.0

apollo-server
  Slowest:	0.0564 secs
  Fastest:	0.0038 secs
  Average:	0.0192 secs
  Requests/sec:	5204.7523
  
benzene-http
  Slowest:	0.0230 secs
  Fastest:	0.0036 secs
  Average:	0.0070 secs
  Requests/sec:	14187.0487
  
benzene-jit-http
  Slowest:	0.0165 secs
  Fastest:	0.0032 secs
  Average:	0.0041 secs
  Requests/sec:	24527.6361
  
express-graphql
  Slowest:	0.0818 secs
  Fastest:	0.0039 secs
  Average:	0.0323 secs
  Requests/sec:	3092.1393
  
graphql-helix
  Slowest:	0.0779 secs
  Fastest:	0.0045 secs
  Average:	0.0316 secs
  Requests/sec:	3153.4511
  
hyper-express-benzene
  Slowest:	0.0128 secs
  Fastest:	0.0004 secs
  Average:	0.0036 secs
  Requests/sec:	27913.0988
  
mercurius
  Slowest:	0.0259 secs
  Fastest:	0.0029 secs
  Average:	0.0050 secs
  Requests/sec:	19885.1838

All with their latest version

  "dependencies": {
    "@benzene/http": "0.4.1",
    "@benzene/jit": "0.1.4",
    "apollo-server": "3.6.3",
    "express-graphql": "^0.12.0",
    "fastify": "3.27.2",
    "graphql-helix": "1.11.0",
    "hyper-express": "5.8.2",
    "mercurius": "9.3.3"
  }

I might not open a PR, but if someone wants, here is what I did.

const { Benzene, makeHandler, parseGraphQLBody } = require("@benzene/http");
const { makeCompileQuery } = require("@benzene/jit");
const HyperExpress = require("hyper-express");
const schema = require("../schema");

const server = new HyperExpress.Server();

const GQL = new Benzene({ schema, compileQuery: makeCompileQuery() });

const graphqlHTTP = makeHandler(GQL);

server.post("/graphql", async (request, response) => {
  const body = await request.json();
  graphqlHTTP({
    method: request.method,
    headers: request.headers,
    body,
  }).then((result) => {
    response.setHeaders(result.headers);
    response.status(result.status).json(result.payload);
  });
});

server.listen(4000);
@redbar0n
Copy link

redbar0n commented May 16, 2023

Check out Elysia (on Bun), it’s now faster than even hyper-express: https://twitter.com/saltyaom/status/1658368305240096769

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants