Boost logo

Boost :

Subject: Re: [boost] [convert] Performance
From: alex (alexhighviz_at_[hidden])
Date: 2014-06-10 09:43:55


>Then I run
>
> for (int k = 0; k < num_tries; ++k)
> {
> double cnv_time = performance::str_to_int(strings,
>boost::cnv::spirit());
> double raw_time = performance_string_to_int_spirit(strings);
>
> printf("str-to-int spirit: raw/cnv=%.2f/%.2f seconds (%.2f%%).\n",
> raw_time, cnv_time, 100 * cnv_time / raw_time);
> }
>
>and regardless if I calculate cnv_time first or raw_time first I get the
>same results (i.e. the first call does not help the second call at all) as
>below:
>
>str-to-int spirit: raw/cnv=1.46/1.42 seconds (97.34%).
>str-to-int spirit: raw/cnv=1.47/1.42 seconds (96.15%).
>str-to-int spirit: raw/cnv=1.46/1.42 seconds (97.31%).
>str-to-int spirit: raw/cnv=1.45/1.42 seconds (97.45%).
>str-to-int spirit: raw/cnv=1.45/1.41 seconds (97.30%).
>
>I give up. My brain is too puny to understand that.
>

Where performance::str_to_int does

BOOST_ASSERT(parse() ), and
BOOST_ASSERT(i == str.end())

performance_string_to_int_spirit does

if !parse() return false.
return i == str.end()

Could it be that the assert function adds some overhead (passing the
filename and linenumber), which explains the difference ?

Alex


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