The benchmarks on this page show results for the following regex engines:
Engine | Description |
---|---|
hyperscan-sequential | Hyperscan, on one CPU core |
hyperscan-parallel | Hyperscan, parallelised on the CPU. |
ipp | Intel IPP, on one CPU core. |
pcre-nojit-sequential | PCRE2, with JIT disabled, on one CPU core. |
pcre-nojit-parallel | PCRE2, with JIT disabled, parallelised on the CPU. |
pcre-jit-sequential | PCRE2, with JIT disabled, on one CPU core. |
pcre-jit-parallel | PCRE2, with JIT enabled, parallelised on the CPU. |
re2 | Google’s RE2 library, single-threaded, on CPU. |
specregex-gpu-nosync | Specregex running on the GPU, with the input data initially in RAM. |
specregex-gpu-sync | Specregex running on the GPU, with the input data initially on the GPU (so copy-to-GPU time is excluded). |
The tests were carried out on a machine with this hardware: - CPU: AMD Ryzen Threadripper 1950X 16-Core Processor - GPU: NVIDIA® Corporation GP104 (NVIDIA GeForce® GTX 1080) - 128GB RAM
Most of the tests involve capture groups, so all engines were run in a mode with capture groups enabled. Since Hyperscan does not support capture groups, it has something of an advantage in these tests because it is effectively allowed to get incorrect results (provided the overall match range is correct).
The Wikinews test applies to all of the articles on Wikinews. These are HTML-formatted news articles.
The results are as follows, and more information about each tested regex is below.
According to
pcre-jit-sequential: 3892.37 MB/s for 17621.98 µs
hyperscan-sequential: 5039.79 MB/s for 13609.95 µs (129.5%) - Success
hyperscan-parallel: 18947.78 MB/s for 3620.02 µs (486.8%) - Success
ipp: 55.05 MB/s for 1245905.61 µs (1.4%) - Success
pcre-nojit-sequential: 248.86 MB/s for 275619.58 µs (6.4%) - Success
pcre-nojit-parallel: 3121.02 MB/s for 21977.21 µs (80.2%) - Success
pcre-jit-parallel: 25053.03 MB/s for 2737.85 µs (643.6%) - Success
re2: 418.15 MB/s for 164033.99 µs (10.7%) - Success
specregex-gpu-nosync: 10608.46 MB/s for 6465.72 µs (272.5%) - Success
specregex-gpu-sync: 60319.04 MB/s for 1137.14 µs (1549.7%) - Success
Dates
pcre-jit-sequential: 1117.96 MB/s for 61354.19 µs
hyperscan-sequential: 3328.69 MB/s for 20606.09 µs (297.7%) - Success
hyperscan-parallel: 25112.59 MB/s for 2731.35 µs (2246.3%) - Success
ipp: 9.96 MB/s for 6883751.71 µs (0.9%) - Success
pcre-nojit-sequential: 162.83 MB/s for 421253.40 µs (14.6%) - Success
pcre-nojit-parallel: 1865.25 MB/s for 36773.30 µs (166.8%) - Success
pcre-jit-parallel: 11385.34 MB/s for 6024.53 µs (1018.4%) - Success
re2: 517.07 MB/s for 132655.03 µs (46.3%) - Success
specregex-gpu-nosync: 10659.74 MB/s for 6434.62 µs (953.5%) - Success
specregex-gpu-sync: 62641.39 MB/s for 1094.98 µs (5603.2%) - Success
Hyphenated words
pcre-jit-sequential: 167.93 MB/s for 408454.18 µs
hyperscan-sequential: 193.24 MB/s for 354959.29 µs (115.1%) - Success
hyperscan-parallel: 2565.44 MB/s for 26736.68 µs (1527.7%) - Success
ipp: 5.77 MB/s for 11877856.51 µs (3.4%) - Success
pcre-nojit-sequential: 20.83 MB/s for 3293422.66 µs (12.4%) - Success
pcre-nojit-parallel: 355.42 MB/s for 192985.88 µs (211.6%) - Success
pcre-jit-parallel: 1875.97 MB/s for 36563.18 µs (1117.1%) - Success
re2: 259.14 MB/s for 264688.96 µs (154.3%) - Success
specregex-gpu-nosync: 6110.12 MB/s for 11225.86 µs (3638.5%) - Success
specregex-gpu-sync: 11618.06 MB/s for 5903.85 µs (6918.4%) - Success
Presidents
pcre-jit-sequential: 2996.46 MB/s for 22890.81 µs
hyperscan-sequential: 4533.29 MB/s for 15130.58 µs (151.3%) - Success
hyperscan-parallel: 26391.89 MB/s for 2598.95 µs (880.8%) - Success
ipp: 132.96 MB/s for 515881.17 µs (4.4%) - Success
pcre-nojit-sequential: 343.55 MB/s for 199652.99 µs (11.5%) - Success
pcre-nojit-parallel: 4257.79 MB/s for 16109.62 µs (142.1%) - Success
pcre-jit-parallel: 23098.77 MB/s for 2969.48 µs (770.9%) - Success
re2: 492.60 MB/s for 139243.60 µs (16.4%) - Success
specregex-gpu-nosync: 10905.50 MB/s for 6289.61 µs (363.9%) - Success
specregex-gpu-sync: 70826.90 MB/s for 968.44 µs (2363.7%) - Success
Combined
pcre-jit-sequential: 134.81 MB/s for 508790.71 µs
hyperscan-sequential: 190.17 MB/s for 360689.50 µs (141.1%) - Success
hyperscan-parallel: 2517.88 MB/s for 27241.70 µs (1867.7%) - Success
ipp: 3.37 MB/s for 20365510.45 µs (2.5%) - Success
pcre-nojit-sequential: 16.46 MB/s for 4167702.93 µs (12.2%) - Success
pcre-nojit-parallel: 254.33 MB/s for 269697.37 µs (188.7%) - Success
pcre-jit-parallel: 1495.19 MB/s for 45874.66 µs (1109.1%) - Success
re2: 98.88 MB/s for 693711.55 µs (73.3%) - Success
specregex-gpu-nosync: 5180.66 MB/s for 13239.88 µs (3842.9%) - Success
specregex-gpu-sync: 8670.61 MB/s for 7910.79 µs (6431.6%) - Success
[Aa]ccording to ([^,]+),
This regex is intended to be an easy case for any engine that implements any kind of efficient literal-based filtering.
[Pp]resident ([^,.:;!]+) said
Similar to “According to”, but with a quantifier in the middle that derails some kinds of literal filtering.
([123]?[0-9])(?:st|nd|rd|th)? (Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|Jun(?:e)?|Jul(?:y)?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?) ((?:19|20)[0-9]{2})
This regex is designed to exercise what happens when you have a large number of capture groups, and quite a lot of matches.
([A-Z]?[a-z]+)-([A-Z]?[a-z]+)
This regex is designed to have two properties that are a nightmare for conventional regex engines:
All of the above, at the same time.
This dataset consists of the body of 100000 tweets.
Hashtag
pcre-jit-sequential: 675.75 MB/s for 10399.35 µs
hyperscan-sequential: 314.95 MB/s for 22312.86 µs (46.6%) - Success
hyperscan-parallel: 1300.71 MB/s for 5402.67 µs (192.5%) - Success
ipp: 79.08 MB/s for 88860.02 µs (11.7%) - Success
pcre-nojit-sequential: 520.27 MB/s for 13507.11 µs (77.0%) - Success
pcre-nojit-parallel: 2550.35 MB/s for 2755.44 µs (377.4%) - Success
pcre-jit-parallel: 2728.09 MB/s for 2575.92 µs (403.7%) - Success
re2: 450.68 MB/s for 15592.86 µs (66.7%) - Success
specregex-gpu-nosync: 4036.60 MB/s for 1740.90 µs (597.4%) - Success
specregex-gpu-sync: 13682.66 MB/s for 513.59 µs (2024.8%) - Success
Retweet
pcre-jit-sequential: 355.18 MB/s for 19785.02 µs
hyperscan-sequential: 182.12 MB/s for 38586.07 µs (51.3%) - Success
hyperscan-parallel: 1202.48 MB/s for 5844.03 µs (338.6%) - Success
ipp: 67.25 MB/s for 104500.85 µs (18.9%) - Success
pcre-nojit-sequential: 252.90 MB/s for 27786.46 µs (71.2%) - Success
pcre-nojit-parallel: 1854.66 MB/s for 3789.01 µs (522.2%) - Success
pcre-jit-parallel: 2208.53 MB/s for 3181.91 µs (621.8%) - Success
re2: 266.07 MB/s for 26411.22 µs (74.9%) - Success
specregex-gpu-nosync: 3764.61 MB/s for 1866.68 µs (1059.9%) - Success
specregex-gpu-sync: 10902.55 MB/s for 644.56 µs (3069.5%) - Success
Trump
pcre-jit-sequential: 1080.66 MB/s for 6502.85 µs
hyperscan-sequential: 811.46 MB/s for 8660.13 µs (75.1%) - Success
hyperscan-parallel: 2097.25 MB/s for 3350.74 µs (194.1%) - Success
ipp: 680.43 MB/s for 10327.72 µs (63.0%) - Success
pcre-nojit-sequential: 200.18 MB/s for 35105.68 µs (18.5%) - Success
pcre-nojit-parallel: 1645.97 MB/s for 4269.41 µs (152.3%) - Success
pcre-jit-parallel: 2942.33 MB/s for 2388.36 µs (272.3%) - Success
re2: 259.51 MB/s for 27079.71 µs (24.0%) - Success
specregex-gpu-nosync: 4313.62 MB/s for 1629.11 µs (399.2%) - Success
specregex-gpu-sync: 17129.02 MB/s for 410.26 µs (1585.1%) - Success
URL
pcre-jit-sequential: 265.58 MB/s for 26460.21 µs
hyperscan-sequential: 156.66 MB/s for 44858.05 µs (59.0%) - Success
hyperscan-parallel: 1095.31 MB/s for 6415.85 µs (412.4%) - Success
ipp: 8.27 MB/s for 849552.23 µs (3.1%) - Success
pcre-nojit-sequential: 57.67 MB/s for 121846.32 µs (21.7%) - Success
pcre-nojit-parallel: 678.25 MB/s for 10360.91 µs (255.4%) - Success
pcre-jit-parallel: 2061.79 MB/s for 3408.36 µs (776.3%) - Success
re2: 105.29 MB/s for 66740.14 µs (39.6%) - Success
specregex-gpu-nosync: 2035.69 MB/s for 3452.06 µs (766.5%) - Success
specregex-gpu-sync: 3139.91 MB/s for 2238.07 µs (1182.3%) - Success
Combined
pcre-jit-sequential: 110.79 MB/s for 63427.19 µs
hyperscan-sequential: 62.18 MB/s for 113024.83 µs (56.1%) - Success
hyperscan-parallel: 587.63 MB/s for 11958.87 µs (530.4%) - Success
ipp: 6.87 MB/s for 1023132.18 µs (6.2%) - Success
pcre-nojit-sequential: 35.73 MB/s for 196690.05 µs (32.2%) - Success
pcre-nojit-parallel: 318.93 MB/s for 22034.04 µs (287.9%) - Success
pcre-jit-parallel: 601.19 MB/s for 11689.03 µs (542.6%) - Success
re2: 52.26 MB/s for 134478.10 µs (47.2%) - Success
specregex-gpu-nosync: 2177.25 MB/s for 3227.61 µs (1965.1%) - Success
specregex-gpu-sync: 2242.53 MB/s for 3133.67 µs (2024.1%) - Success
#([A-Za-z0-9_.-]+)
RT @([A-Za-z0-9_.-]+)
[Tt]rump
This regex is amenable to prefix filtering, matches huge numbers of times, and is a good test of how the kernel copes with many short matches across many small strings.
([a-z]+)://([a-z0-9_.-]+)(:[0-9]+)?([A-Za-z0-9_.%#/?-]*)
Not a perfect URL regex (those are enormously complicated), but close enough.
All of the above, at the same time.