Jeff Garland wrote:
Keeping in mind John's caveats, I find the language shootout website to be an interesting way to compare. Here's a c++ vs perl results:
http://shootout.alioth.debian.org/gp4/benchmark.php?test=all&lang=gpp&lang2=perl
http://shootout.alioth.debian.org/gp4/benchmark.php?test=regexdna&lang=all
The regex-dna test is written using boost-regex and tests out ~2.4 times slower and with a larger memory footprint than the perl version. Note that this is the *only* benchmark where perl outperforms c++.
:-(
That said, it's one data point and what you're doing may have totally different results. That's not to mention the effect of the compiler -- gcc doesn't have a greatest reputation for optimization although it's been improving. And, you're also depending on other programmers to write good benchmarks.
Yep, looking at the source code for the test, my first impression is that most of the time is likely to be taken up with the iostream code. I also notice that the C-language PCRE test takes almost exactly the same amount of time as the two C++ / Boost-Regex tests, in spite of avoiding high level constructs like std::string. Might be tempting to try and do better... Cheers, John.