Boost logo

Boost :

Subject: Re: [boost] [xpressive] Performance Tuning?
From: Joel de Guzman (joel_at_[hidden])
Date: 2009-07-30 21:19:53

Giovanni Piero Deretta wrote:
> *scratches head*
> I must be missing something very obvious, but I do not see how your
> and OvermindDL benchmarks can support this conclusion: as far as I can
> tell, you two never compared the two compilers directly, what you are
> seeing is that on GCC the speed up of qi_parse over atoi/strtol is
> less than that of MSVC, but this tells nothing about the absolute
> performance of the two compilers on this test (i.e. you never showed
> any absolute times).
> For what we know the gcc atoi might just be faster than msvc one. And
> in fact a quick google search brings these two pages:
> [msvc8 atoi performance is 58% of that of msvc6]
> [thread containing a comparison of atoi
> functions of different languages and compilers, in particular it seems
> that MSVC atoi is really 2 times slower than gcc atoi]
> A slow atoi on MSVC would explain such a difference in the tests,
> assuming that the ability of both compilers to optimize qi_parse is
> about the same.
> Finally, I see from the error messages that OvermindDL is using
> gcc.3.4, which is now fairly old, maybe he should try with a more
> recent one. Also -march=native or whatever architecture he is using
> might help.

Here are my tests with absolute numbers on one machine:

atoi_test: 6.8413257003 [s]
strtol_test: 6.5168116888 [s]
spirit_int_test: 2.0843406163 [s]

atoi_test: 6.6410000000 [s]
strtol_test: 6.2970000000 [s]
spirit_int_test: 1.8280000000 [s]

I'm starting to get impressed with g++ optimizations.

If you want to verify the results, you can try it out from the
boost SVN trunk at BOOST_ROOT/libs/spirit/benchmarks/qi/int_parser.cpp

Here are my floating point tests:

atof_test: 8.4475158037 [s]
strtod_test: 8.9236700525 [s]
spirit_double_test: 2.9671239036 [s]

atof_test: 12.4380000000 [s]
strtod_test: 12.5940000000 [s]
spirit_double_test: 2.7030000000 [s]

Now that's rockin!

In any case, this goes to show that Spirit numeric parsers are way
faster than the corresponding low-level C routines. It shows that
you can write extremely tight generic C++ code that rivals, if not
surpasses C.


Joel de Guzman

Boost list run by bdawes at, gregod at, cpdaniel at, john at