fastify/benchmarks

[Feature] Add percentage value to cells

lependu opened this issue · 2 comments

Hi! I created a small feature which adds percentage value to the cells based on the fastest choice. I think it is easier to compare this way. You can check the code here.

$ node benchmark-compare.js -t -p will output table like this:

┌─────────┬─────────┬────────┬─────────────┬─────────────┬───────────────┐
│         │ Version │ Router │ Requests/s  │ Latency     │ Throughput/Mb │
│         │         │        │ (% of bare) │ (% of bare) │ (% of bare)   │
├─────────┼─────────┼────────┼─────────────┼─────────────┼───────────────┤
│ bare    │ 8.11.2  │ ✗      │ 10714.8     │ 9.13        │ 1.52          │
│         │         │        │ (100.00)    │ (100.00)    │ (100.00)      │
├─────────┼─────────┼────────┼─────────────┼─────────────┼───────────────┤
│ micro   │ 9.3.2   │ ✗      │ 10595.6     │ 9.25        │ 1.66          │
│         │         │        │ (98.89)     │ (101.31)    │ (109.05)      │
├─────────┼─────────┼────────┼─────────────┼─────────────┼───────────────┤
│ fastify │ 1.6.0   │ ✓      │ 10065.21    │ 9.73        │ 1.57          │
│         │         │        │ (93.94)     │ (106.57)    │ (103.29)      │
├─────────┼─────────┼────────┼─────────────┼─────────────┼───────────────┤
│ express │ 4.16.3  │ ✓      │ 5806.8      │ 16.82       │ 0.90          │
│         │         │        │ (54.19)     │ (184.23)    │ (59.47)       │
└─────────┴─────────┴────────┴─────────────┴─────────────┴───────────────┘

If you like it, I happy to create a PR.

Hello @lependu -Thank you for this. I think this would be handy to have in the results table. Please do create a PR. As for your questions;

Keep/extend the tests or clean them up

You can use the current test and extend them. There is always room for improvement, so cleaning them up is also welcome.

Keep utils and this feature in seperate file or refactor them into benchmark-compare.js

You can refactor this into benchmark-compare.js, much like the -t option currently works.

Sorting is hardcoded based on requests.mean. May I expose other options (latency, throughput) with additional command line argument

The sorting is good like that. I don't understand the second part about exposing other options.

@aichholzer
Sorry, I didn't think it through well. All of those questions it the original message overcomplicate things, and could be a separate issue, so I deleted them to avoid further confusion. 😳
I create a PR with minimal implementation.