pedronauck / micro-router

:station: A tiny and functional router for Zeit's Micro
https://www.npmjs.com/microrouter
MIT License
621 stars 34 forks source link

Fastify benchmark lists this package as a performance killer #47

Open brandonros opened 6 years ago

brandonros commented 6 years ago

https://github.com/fastify/fastify

Framework Version Router? Requests/sec
micro (microrouter) 9.1.0 (microrouter@3.1.1 ) 18,314
micro 9.1.0 31,793

Is this out of date or accurate? Can anything be done to make this package not be a performance killer?

ilionic commented 6 years ago

Also interested in this subject. My wild guess culprit could be url / url-pattern as it's relying on some [slow] regex.

ilionic commented 6 years ago

Tried https://github.com/petkaantonov/urlparser Some benchmarks:

With node url:

 Both are awesome but micro is 67.92% faster than microrouter
 • micro request average is 13524
 • microrouter request average is 8054
✨  Done in 4.86s.

With fast-url-parser:

 Both are awesome but micro is 51.92% faster than microrouter
 • micro request average is 14260
 • microrouter request average is 9386.4
✨  Done in 3.48s.

So there are some improvements as you can see. I can send PR ( using fastify benchmarks https://github.com/fastify/benchmarks )

Looks like should be possible to boost more performance refactoring url-pattern