Skip to content

gnaaman-dn/regex-benchmarks

Repository files navigation

Tests a bunch of regexes against some input lines. This specifically doesn't try to find all occurrences of a pattern, but tries to match the whole string against the pattern, as we try to emulate validation.

To run, clone this repo and run make. First run might take a while since cargo tries to download its index, but subsequent should be faster.

Example results from my machine: (Intel(R) Xeon(R) CPU E5-2650 v3 @ 2.30GHz)

    cpp_hyperscan         rust      python                                                                            regex
0      296.642459   313.477929  5468.16452                                      ^((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)\.?\b){4}$
1      333.053143   303.561480  3440.85922  ^((([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])[.]){3}([0-9]|[1-9][0-9...
2      255.655666   276.322356  2695.76003  ^(((:|[0-9A-Fa-f]{0,4}):)([0-9A-Fa-f]{0,4}:){0,5}((([0-9A-Fa-f]{0,4}:)?(:|[0...
3      431.463312   516.112037  7484.01809  (([^:]+:){6}(([^:]+:[^:]+)|(.*\..*)))|((([^:]+:)*[^:]+)?::(([^:]+:)*[^:]+)?)...
4      415.915523   220.289527  9450.14273  ((([a-zA-Z0-9_]([a-zA-Z0-9\-_]){0,61})?[a-zA-Z0-9]\.)*([a-zA-Z0-9_]([a-zA-Z0...
5      225.102598   594.831152  2601.78721  (([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1...
6      395.676644   515.071103  2652.32615  ((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}((([0-9a-fA-F]{0,4}:)?(:|[0-9...
7      439.094160   511.437599  7489.82166  (([^:]+:){6}(([^:]+:[^:]+)|(.*\..*)))|((([^:]+:)*[^:]+)?::(([^:]+:)*[^:]+)?)...
8      313.659211   186.651890  2089.99427                                                                               \*
9      198.908448   512.458027  2206.40600                                                                \d{4}-\d{2}-\d{2}
10     137.704878   166.940905  2111.79947                                                                         infinity
11     286.654086   213.551516  2188.17237                                                                           unused
12     261.699810   204.583877  2190.70109                                                                          blocked
13     365.317192   872.037533  2869.23314  (6553[0-4]|655[0-2][0-9]|65[0-4][0-9]{2}|6[0-4][0-9]{3}|[1-5][0-9]{4}|[1-9][...
14     225.464139   560.070383  2615.23396  (([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1...
15     363.644474  1018.489042  3441.97384  (429496729[0-5]|42949672[0-8][0-9]|4294967[0-1][0-9]{2}|429496[0-6][0-9]{3}|...
16     346.073838  1018.331178  3439.00782  (429496729[0-5]|42949672[0-8][0-9]|4294967[0-1][0-9]{2}|429496[0-6][0-9]{3}|...
17     348.014329  1029.299411  3460.79009  (429496729[0-5]|42949672[0-8][0-9]|4294967[0-1][0-9]{2}|429496[0-6][0-9]{3}|...
18     356.043361   566.111958  3152.97860  (([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1...

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published