Re:R3 bindings for Node.js
by pygy_ on Friday July 18, 2014 @08:56AM
(#8052735)
It pre-compiles routes to a prefix trie [0], which allows it to match any route in one run by walking down the tree rather than trying each route from scratch. Nginx uses the same strategy for static routes.
Re:R3 bindings for Node.js
by phpnode on Friday July 18, 2014 @11:00AM
(#8053373)
R3 does look fast, but there's a cost to crossing the JS -> C barrier. It's almost certainly possible to beat it using the same algorithm written in pure JS.
Re:R3 bindings for Node.js
by sjtgraham on Friday July 18, 2014 @09:28AM
(#8052875)
Finding a match in a tree structure is asymptotically O(log n), finding a match in a list is O(n). This router is also written in C.
There is a benchmark in the README comparing R3 to the Rails router and also to a replacement Rails router that I wrote for non-performance related reasons.
It should be noted that usually only a tiny proportion of the time taken to respond to a request is spent in route recognition. YMMV.
————
0. https://en.wikipedia.org/wiki/Trie
There is a benchmark in the README comparing R3 to the Rails router and also to a replacement Rails router that I wrote for non-performance related reasons.
It should be noted that usually only a tiny proportion of the time taken to respond to a request is spent in route recognition. YMMV.
https://github.com/c9s/r3#performance
https://github.com/freehaha/go-r3