Boost logo

Boost :

Subject: Re: [boost] [xpressive] Performance Tuning?
From: Edward Grace (ej.grace_at_[hidden])
Date: 2009-07-19 19:15:04


Hi Joel,

> I tried a quick shot at it. There are compilation errors indeed.
> Please try to fix the errors first (*). You can get Spirit by getting
> the Boost trunk off SVN.

Ok, once I knew where to look it was easy to get sorted. I've placed
my example - based on your code - in the vault.

A typical example using a much smaller buffer (1000) vs (1000000) by
altering what you called MAX_ITERATION yields the following eye-
popping stats:

$ time ./ejg_uint_parser
initializing input strings...
Calibrating overhead......done
Timer overhead (t_c) ~= : 0.000195267
Jitter ~= : 2.02505e-14
qi_parse vs atoi : 1656.34 1661.63 1683.63% faster.
qi_parse vs strtol : 1521.71 1534.68 1547.75% faster.
strtol vs atoi : 4.17706 8.94977 10.1224% faster.
qi_parse vs qi_parse : -6.26613 -3.19258 -0.0182475% faster.

Checking that the results are correct...
atoi is behaving itself!
strtol is behaving itself!
qi is behaving itself!

All done!

real 7m37.575s
user 6m47.978s
sys 0m29.151s

N.B. The final timing of qi_parse against itself is zero percent
within the nominal precision. At first I thought the 1000% speedup
of qi_parse was a fake due to some compiler shenanigans. Now I don't
think so. I think it really is that much faster for small buffers!
Note that this timing experiment took ~6mins.

Using cycle.h:

This was all compiled with:

g++-4 -ansi -pedantic -DNDEBUG -O4 -I. -I spirit21_root -I $HOME/
Desktop/boost_1_39_0 -o ejg_uint_parser ejg_uint_parser.cpp

Where spirit21_root is the spirit library I downloaded earlier. It
passes the -ansi -pedantic test and is optimized to the max.

Repeating this with getticks() from cycle.h instead of the boost
based timer we get:

$ time ./ejg_uint_parser
initializing input strings...
Calibrating overhead......done
Timer overhead (t_c) ~= : 145.797
Jitter ~= : 5.31361
qi_parse vs atoi : 1672.05 1674.47 1677.3% faster.
qi_parse vs strtol : 1543.36 1547.38 1555.7% faster.
strtol vs atoi : 7.39392 7.79078 7.84302% faster.
qi_parse vs qi_parse : 0 0 0% faster.

Checking that the results are correct...
atoi is behaving itself!
strtol is behaving itself!
qi is behaving itself!

All done!

real 0m25.254s
user 0m22.124s
sys 0m2.496s

Same results - actually better since the experiment is quicker and
the 95th percentile range is therefore narrower. Obviously I'm
suspicious that something funny's going on - would you expect it to
be capable of being ~10x faster?

> (*) Also, please make sure you try it on Windows too. E.g. <sys/
> time.h>
> is non-standard, AFAIK. My main compiler is VC9. Your library is
> intended to be cross platform, right?

Can you try compiling ejg_uint_parser.cpp?

    http://tinyurl.com/klh2hc

Like I say it's -ansi -pedantic, so 'gotta work'! ;-)

-ed

------------------------------------------------
"No more boom and bust." -- Dr. J. G. Brown, 1997


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk