You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The literal characters `{` and `}` may be included in a static route by escaping them with the same character. For example, the `{` character is escaped with `{{` and the `}` character is escaped with `}}`.
62
+
The literal characters `{` and `}` may be included in a static route by escaping them with the same character.
63
+
For example, the `{` character is escaped with `{{` and the `}` character is escaped with `}}`.
The router takes advantage of the fact that URL routes generally follow a hierarchical structure. Routes are stored them in a radix trie that makes heavy use of common prefixes.
90
+
The router takes advantage of the fact that URL routes generally follow a hierarchical structure.
91
+
Routes are stored them in a radix trie that makes heavy use of common prefixes.
90
92
91
93
```text
92
94
Priority Path Value
@@ -102,34 +104,40 @@ Priority Path Value
102
104
1 └contact\ 8
103
105
```
104
106
105
-
This allows us to reduce the route search to a small number of branches. Child nodes on the same level of the tree are also prioritized
106
-
by the number of children with registered values, increasing the chance of choosing the correct branch of the first try.
107
+
This allows us to reduce the route search to a small number of branches. Child nodes on the same level of the tree are also
108
+
prioritized by the number of children with registered values, increasing the chance of choosing the correct branch of the first try.
107
109
108
110
## Benchmarks
109
111
110
-
As it turns out, this method of routing is extremely fast. In a benchmark matching 4 paths against 130 registered routes, `matchit` find the correct routes
111
-
in under 200 nanoseconds, an order of magnitude faster than most other routers. You can view the benchmark code [here](https://github.com/ibraheemdev/matchit/blob/master/benches/bench.rs).
112
+
As it turns out, this method of routing is extremely fast. Below are the benchmark results matching against 130 registered routes.
113
+
You can view the benchmark code [here](https://github.com/ibraheemdev/matchit/blob/master/benches/bench.rs).
112
114
113
115
```text
114
116
Compare Routers/matchit
115
-
time: [175.96 ns 176.39 ns 176.84 ns]
117
+
time: [2.4451 µs 2.4456 µs 2.4462 µs]
116
118
117
-
Compare Routers/actix
118
-
time: [26.805 us 26.811 us 26.816 us]
119
+
Compare Routers/gonzales
120
+
time: [4.2618 µs 4.2632 µs 4.2646 µs]
119
121
120
122
Compare Routers/path-tree
121
-
time: [468.95 ns 470.34 ns 471.65 ns]
123
+
time: [4.8666 µs 4.8696 µs 4.8728 µs]
122
124
123
-
Compare Routers/regex
124
-
time: [22.539 us 22.584 us 22.639 us]
125
+
Compare Routers/wayfind
126
+
time: [4.9440 µs 4.9539 µs 4.9668 µs]
125
127
126
128
Compare Routers/route-recognizer
127
-
time: [3.7552 us 3.7732 us 3.8027 us]
129
+
time: [49.203 µs 49.214 µs 49.226 µs]
128
130
129
131
Compare Routers/routefinder
130
-
time: [5.7313 us 5.7405 us 5.7514 us]
132
+
time: [70.598 µs 70.636 µs 70.670 µs]
133
+
134
+
Compare Routers/actix
135
+
time: [453.91 µs 454.01 µs 454.11 µs]
136
+
137
+
Compare Routers/regex
138
+
time: [421.76 µs 421.82 µs 421.89 µs]
131
139
```
132
140
133
141
## Credits
134
142
135
-
A lot of the code in this package was based on Julien Schmidt's [`httprouter`](https://github.com/julienschmidt/httprouter).
143
+
A lot of the code in this package was inspired by Julien Schmidt's [`httprouter`](https://github.com/julienschmidt/httprouter).
0 commit comments