Boost logo

Boost :

Subject: Re: [boost] [xpressive] Performance Tuning?
From: Eric Niebler (eric_at_[hidden])
Date: 2009-07-01 18:09:37

Dave Jenkins wrote:
> Robert Stuart wrote:
>> Whoa! The performance just shot up to a mere 6X the custom code (from
>> 175X). That might well be fast enough to keep the Xpressive version
>> because of its readability!
> Can you create thread-local match_results objects and reuse them? If
> so, I think you'll see parsing dwindle to almost nothing and your
> semantic actions will account for the bulk of the time spent.

Dave, thanks for spotting the obvious perf problem I missed. I can
confirm that reusing the match results object largely eliminates the
remaining performance problem. I tried 3 different scenarios:

1) The original code
2) Static const regexes
3) Static const regexes with reused match results objects

I ran each config for 1000000 iterations and got roughly these numbers:

1) ~950 sec
2) ~45 sec
3) ~9 sec

So reusing the match results object (3) results in a 5x speedup over
just using static const regexes (2). That almost completely erases any
performance advantage of the hand-crafted parsing code.

I'll also point out this section of the docs:

Both of the above optimizations (reuse regexes and match_results
objects) are recommended there.


Eric Niebler
BoostPro Computing

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