Skip to content

kingluo/routerify-lite

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Routerify lite

Routerify-lite is a simplified but faster version of Routerify.

It only provides the below functions:

  • path matching (including :param segment captures)

The path matching could be done by RegexSet or HashMap. It would use RegexSet if the path contains * or :param. Otherwise, HashMap would be used.

  • error handling

The error handler would translate the request into a response in case of an error from the route handler.

Check the examples here: examples

Why not Routerify?

Routerify is an excellent lib! But sometimes it performs not so well. So I rewrite some code paths to improve performance. If you need the full functions, you must use Routerify.

Why not warp?

Warp is fast. But due to its linear scan path matching, it would be as slow as the number of API combination increase. However, Routerify uses RegexSet, which could match the URI path towards the pattern list in one scan.

For example, I add 50 random URIs to match, then routerify-lite is better than warp.

Check the code here:

https://gist.github.com/kingluo/8ccd88b53e9d2878391dbb91ad1f4751

wrk -t2 -c100 -d60s http://test1:8080/hello/world

Performance2

Performance

Performance 1

wrk -t2 -c100 -d60s http://test1:8080

Performance

Check the code here:

https://gist.github.com/kingluo/73592448153fcc0e48788a5f9080b3bd

Performance 2

Routerify-lite uses HashMap; 50 URI patterns.

wrk -t2 -c100 -d60s http://test1:8080

Performance

You could see that both HashMap and RegexSet are better than linear scan.

About

A simplified but faster version of Routerify

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages