Boost logo

Boost :

Subject: Re: [boost] [xpressive] Performance Tuning?
From: John Bytheway (jbytheway+boost_at_[hidden])
Date: 2009-07-19 15:15:35

Joel de Guzman wrote:
> John Bytheway wrote:
>> string::begin() return a non-const reference?), but anyway. Here are
>> the icc results (Intel Core2 Quad 2.83GHz, Gentoo):
>> Loop count: 10000000
>> Parsing: 42.5
>> xpressive: 4.28591
>> spirit-quick(static): 1.4721
>> spirit-quick_new(threadsafe): 1.46949
>> spirit-grammar(threadsafe/reusable): 1.59846
>> and gcc-4.4.0:
>> Loop count: 10000000
>> Parsing: 42.5
>> xpressive: 3.62948
>> spirit-quick(static): 1.02657
>> spirit-quick_new(threadsafe): 1.00637
>> spirit-grammar(threadsafe/reusable): 1.01748
>> gcc 4.3 is still ICEing.
> Those are good numbers. It shows that the effect of the
> virtual function call of the spirit grammar rules is obviated
> out of existence!
> For the record, this one shows the xpressive code using spirit
> numeric parsers to convert the string to numbers, right?


> Will the original OP please (PLEASE!) come forward and post his
> original hand-coded program? This is SOOO confusing!

Well, in case he doesn't, I've thrown together an implementation of
core::to_number based on Robert's description of it. I had to guess at
the interface, and I didn't verify correctness. I also had to implement
two error routines; I made them both "throw 0;".

I also tweaked the xpressive code so that it didn't copy the sub_match
objects to strings before using qi to parse out the doubles and ints.
That sped it up slightly (gcc 4.4.0 again):

Loop count: 10000000
Parsing: 42.5
original-custom: 2.08637
xpressive: 2.94329
spirit-quick(static): 1.02784
spirit-quick_new(threadsafe): 1.03306
spirit-grammar(threadsafe/reusable): 1.00213

although I'm slightly concerned with what happened when I changed the
string to be parsed:

Loop count: 10000000
Parsing: 425/500
original-custom: 1.6307
xpressive: 116.992
spirit-quick(static): 0.552722
spirit-quick_new(threadsafe): 0.53429
spirit-grammar(threadsafe/reusable): 0.680257

Why is the xpressive code so slow here? The parsing is more complex in
this case, but I wouldn't think it was this bad! Perhaps I broke it

New code attached (also includes other minor changes I had to make to
get things to compile).

If someone writes core::numeric_cast then the 'original' xpressive code
can be used.

John Bytheway

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