Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>These benchmarks aren't really comparable -- C++ and .NET implement completely different regular expression languages (ECMAScript vs. Perl), and are powered by completely different regular expression engines. .NET (to my understanding) is benefiting from the <a href="http://research.microsoft.com/en-us/downloads/bd99f343-4ff4-4041-8293-34c054efe749/default.aspx">GRETA project</a> here, which produced an absolutely fantastic regular expression engine which has been tuned for years. The C++ <code>std::regex</code> in comparison is a recent addition (at least on MSVC++, which I'm assuming you're using given the nonstandard types <code>__int64</code> and friends).</p> <p>You can see how GRETA did vs. a more mature <code>std::regex</code> implementation, <code>boost::regex</code>, here: <a href="http://www.boost.org/doc/libs/1_54_0/libs/regex/doc/vc71-performance.html">http://www.boost.org/doc/libs/1_54_0/libs/regex/doc/vc71-performance.html</a> (though that test was done on Visual Studio 2003).</p> <p>You also should keep in mind that regex performance is highly dependent on your source string and on your regex. Some regex engines spend lots of time parsing the regex to go faster through more source text; a tradeoff that makes sense only if you are parsing lots of text. Some regex engines trade off scanning speed for being relatively expensive to make matches (so number of matches would have an effect). There are huge numbers of tradeoffs here; one pair of inputs really is going to cloud the story.</p> <p>So to answer your question more explicitly: this kind of variation is normal across regex engines, be they compiled or interpreted. Looking at boost's tests above, often the difference between the fastest and slowest implementations were hundreds of times different -- 17x isn't all that strange depending on your use case.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload