the original test environmet by dark100 at

clone this test environmet

Performance comparison of regular expression engines


Processing text or raw byte-sequence are among the common tasks performed by most software tools. These tasks usually involve pattern matching algorithms, and the most popular tool for such purpose is regular expressions. Regular expressions has been evolved a lot since Kleene defined the regular sets in the 1950's. Today we have several widely used regular expression engines which have different features which makes any performance comparison a difficult task, since a faster engine is not necessary better. Depending on the use case it might be enough to know whether a POSIX compatible regular expression matches to a line, even the position of the match is unneeded (grep utility). On the contrary other use cases require the position of capturing brackets, unicode support, conditional and atomic block (handling a byte sequence as a single character, like 'sch' in German language) support just to name a few. The former case needs a less sophisticated algorithm, which is likely be much faster than the latter, but again, that does not mean the former is better. More about these engine types can be found here.


The following popular engines were choosen: and Before anyone jump to any conclusions, I should note the followings:


x86-64 bit Intel Cerelon 847 1.1GHz (GCC 7.2.0, Go 1.9.1 – GNU/Linux)

Regular expressiontrere2Golangre2pcre-JITpcre-DFApcreonigregexp4Golangregexp4regexp3
6486ms (19285324)34159ms (19285324)9072ms (19285324)1130ms (19285324)6677ms (19285324)4448ms (19285324)12876ms (19285324)1553ms (19285324)605ms (19285324)1808ms (19285324)
1044ms (27084)3166ms (27084)134ms (27084)55ms (27084)68ms (27084)65ms (27084)127ms (27084)1340ms (27084)594ms (27084)1853ms (27084)
4633ms (15451664)32530ms (15451664)7405ms (15451664)931ms (15451664)4593ms (15451664)3086ms (15451664)10453ms (15451664)2056ms (15451664)810ms (15451664)1912ms (15451664)
2565ms (3414592)8000ms (3414592)1957ms (3414592)333ms (3414592)1619ms (3414592)924ms (3414592)3114ms (3414592)1521ms (3414592)654ms (3414592)1059ms (3414592)
4769ms (14751878)32506ms (14751878)7052ms (14751878)952ms (14751878)4537ms (14751878)2994ms (14751878)10865ms (14751878)1811ms (14750958)819ms (14750958)1888ms (14750958)
4762ms (14751878)29682ms (14751878)7066ms (14751878)952ms (14751878)4486ms (14751878)2989ms (14751878)10663ms (14751878)2472ms (14751878)1160ms (14751878)3171ms (14751878)
4650ms (14751878)29437ms (14751878)7121ms (14751878)994ms (14751878)4538ms (14751878)3074ms (14751878)10483ms (14751878)2735ms (14751878)1104ms (14751878)5260ms (14751878)
2317ms (3495761)7582ms (3495761)2048ms (3495761)327ms (3495761)1551ms (3495761)1007ms (3495761)2956ms (3495761)2250ms (3495761)860ms (3495761)2771ms (3495761)
2205ms (991813)9541ms (3430783)2036ms (3430783)399ms (3430783)1037ms (3430783)949ms (3430783)2676ms (3430783)2851ms (3430783)1363ms (3430783)3741ms (3430783)
1591ms (314387)5611ms (314387)430ms (314387)82ms (314387)1038ms (314387)210ms (314387)697ms (314387)1301ms (314387)578ms (314387)788ms (314387)
520ms (1781425)2842ms (1781425)1000ms (1781425)139ms (1781425)439ms (1781425)380ms (1781425)1434ms (1781425)1739ms (1781425)663ms (1781425)1809ms (1781425)
529ms (1781425)4399ms (1781425)1001ms (1781425)203ms (1781425)1269ms (1781425)1256ms (1781425)1971ms (1781425)6168ms (1781425)2360ms (1781425)19939ms (1781425)
525ms (1781425)6709ms (1781425)1006ms (1781425)298ms (1781425)1850ms (1781425)1945ms (1781425)2176ms (1781425)12171ms (1781425)4034ms (1781425)58376ms (1781425)
1022ms (2388)12ms (2388)8ms (2388)49ms (2388)47ms (2388)10ms (2388)52ms (2388)1610ms (2388)589ms (2388)2450ms (2388)
1015ms (2388)13ms (2388)8ms (2388)49ms (2388)48ms (2388)14ms (2388)53ms (2388)2294ms (2388)927ms (2388)6027ms (2388)
1337ms (2657)3515ms (2657)166ms (2657)51ms (2657)287ms (2657)203ms (2657)349ms (2657)1616ms (2657)727ms (2657)2575ms (2657)
1375ms (2989)3474ms (2989)168ms (2989)56ms (2989)319ms (2989)236ms (2989)353ms (2989)2154ms (2989)1021ms (2989)9216ms (2989)
1597ms (1877)3614ms (1877)277ms (1877)47ms (1877)2302ms (1877)1487ms (1877)49ms (1877)3250ms (1877)1267ms (1877)5413ms (1877)
1779ms (396)4431ms (396)126ms (396)8ms (396)72ms (396)70ms (396)117ms (396)3894ms (396)1456ms (396)6599ms (396)
4446ms (5021)11181ms (5021)613ms (5021)5ms (5021)6169ms (5021)1742ms (5021)135ms (5021)9796ms (5021)3347ms (5021)10391ms (5021)
3151ms (3015)9003ms (3015)134ms (3015)89ms (3015)96ms (3015)97ms (3015)141ms (3015)6608ms (3015)2608ms (3015)10659ms (3015)
3302ms (3015)8876ms (3015)131ms (3015)87ms (3015)100ms (3015)102ms (3015)142ms (3015)7240ms (3015)2964ms (3015)23149ms (3015)
3656ms (534)4503ms (534)250ms (534)247ms (534)889ms (534)638ms (534)687ms (534)2903ms (534)1589ms (534)10916ms (534)
1844ms (2)4541ms (2)152ms (2)44ms (2)247ms (2)211ms (2)236ms (2)N/AN/AN/A
1149ms (85956)228ms (85956)111ms (85956)54ms (85956)243ms (85956)140ms (85956)140ms (85956)1611ms (85956)627ms (85956)3131ms (85956)
1859ms (85823)3884ms (85823)309ms (85823)56ms (85823)2376ms (85823)1549ms (85823)143ms (85823)3274ms (85823)1328ms (85823)6761ms (85823)
2070ms (95863)5411ms (95863)318ms (95863)213ms (95863)6616ms (95863)4174ms (95863)2603ms (95863)N/AN/AN/A



get data

  1. $ wget
  2. $ dos2unix mtent12.txt data.txt
  3. $ dos2unix data.txt
  4. $ rm mtent12*

build benchmarks

  1. $ ./
  2. $ ./


  1. $ ./