Boost logo

Boost :

Subject: Re: [boost] [xpressive] Performance Tuning?
From: Edward Grace (ej.grace_at_[hidden])
Date: 2009-07-28 11:40:33


>>>
> And heh, Spirit is completely inlined except for the call to
> boost::spirit::qi::detail::extract_int<int,10,1,-1,etc...
> However that function is only called the very first time that function
> is called. Remember that Spirit increments the passed in iterator, so
> all the start iterators in that vector ended up being incremented to
> be equal to the last iterator. :p

When you write the above, do you mean ** -> my change

> However that function is only called the very first time *qi::parse*
> is called. Remember that Spirit increments the passed in iterator, so
>

In other words only the first call does anything - repeated calls to
qi::parse do nothing because the iterator is already at the end?

Good catch.

> I change the wrap_qi_parse function to this (introduced a temporary so
> the temporary is incremented instead of the thing you have stored in
> the vector):
> void wrap_qi_parse() {
> for (int i = 0; i < BUFFER_SIZE; ++i)
> {
> char const *iter = f[i];
> qi::parse(iter, l[i], int_, v[i]);
> }
>
> }
>
> When I compile and run the tests now, I get this:
> initializing input strings...
> Calibrating overhead......done
> Timer overhead (t_c) ~= : 12
> Jitter ~= : 8.43769e-015
> qi_parse vs atoi : 170.429 170.438 170.482% faster.
> qi_parse vs strtol : 167.589 167.601 167.668% faster.
> strtol vs atoi : 1.04669 1.05746 1.06165% 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!

Good stuff. Thanks.

I might just re-jig that to try and make use of boost::bind instead
of that bad roll-your-own wrapper function. What's needed is a 'fire
and forget' wrapping technique that can be applied to arbitrary
functions and still give sensible answers.

> That is a *lot* more reasonable, although Spirit is still most
> definitely faster then the built-in functions. :)

That's good though - one up for Boost!

> Heh, what do you know, my shut down brain still had some living brain
> cells. I have actually found that I, oddly, do my best debugging when
> really tired, at least when I was younger, guess I still do. :)

It's amazing what the promise of imminent sleep can do to motivate a
battered cerebral cortex. It's only playing along because it knows
it's the only way it'll get to rest!

-ed


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