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
* Major performance improvements for `Mustermann::Mapper`, as it is based on `Mustermann::Set` now, and can dispatch in logarithmic time instead of linear time.
59
59
* Major speed improvements for sub-segment patterns with optional elements (like a format at the end of a path). These patterns are common in web applications.
| Matching against 1k patterns | 20x to 350x speedup |
70
-
| Matching against 10k patterns | 200x to 3500x speedup |
71
-
72
-
Numbers are based on simple and realistic patterns run on MRI Ruby 4.0 on a MacBook Pro. The improvements you will see may vary based on your Ruby implementation, platform and patterns used.
73
-
74
-
Simple and complex in the above table refer to patterns with only static segments or captures matching exactly one segment each (like `/resource/:id` or `/:controller/:action`) versus patterns with more complex captures (like `/resource/*path/:id` or `/resource/:id(.:format)?`). The matching improvements against 1k and 10k patterns assume the new `Mustermann::Set` is used. Otherwise the difference should be in line with the single pattern matching improvements.
61
+
<table>
62
+
<thead>
63
+
<tr>
64
+
<th colspan="2">Scenario</th>
65
+
<th>Mustermann 3.1</th>
66
+
<th>Mustermann 4.0</th>
67
+
<th>Improvement</th>
68
+
</tr>
69
+
</thead>
70
+
<tbody>
71
+
<tr>
72
+
<td rowspan="5">Simple patterns</td>
73
+
<td>Compilation</td>
74
+
<td>12.1 K/s</td>
75
+
<td>70.8 K/s</td>
76
+
<td>6x</td>
77
+
</tr>
78
+
<tr>
79
+
<td>Matching non-repeating strings</td>
80
+
<td>4.5 M/s</td>
81
+
<td>4.5 M/s</td>
82
+
<td>none</td>
83
+
</tr>
84
+
<tr>
85
+
<td>Matching repeating strings</td>
86
+
<td>5.9 M/s</td>
87
+
<td>17.1 M/s</td>
88
+
<td>3x</td>
89
+
</tr>
90
+
<tr>
91
+
<td>Extracting params</td>
92
+
<td>0.7 M/s</td>
93
+
<td>2.2 M/s</td>
94
+
<td>3x</td>
95
+
</tr>
96
+
<tr>
97
+
<td>Matching against 1k different patterns</td>
98
+
<td>3 M/s</td>
99
+
<td>7.1 K/s</td>
100
+
<td>425x</td>
101
+
</tr>
102
+
<tr>
103
+
<td rowspan="2">Complex patterns</td>
104
+
<td>Extracting params</td>
105
+
<td>486 K/s</td>
106
+
<td>955 K/s</td>
107
+
<td>2x</td>
108
+
</tr>
109
+
<tr>
110
+
<td>Matching against malicious input</td>
111
+
<td>3.6 K/s</td>
112
+
<td>582 K/s</td>
113
+
<td>162x</td>
114
+
</tr>
115
+
</tbody>
116
+
</table>
117
+
118
+
Higher numbers are better.
119
+
120
+
Performance measured on local development machine (MacBook Pro 2024, Ruby 4.0.2) with the `bench/versions.rb` script, which measures single-threaded performance.
0 commit comments