Subject: Re: [boost] [convert] Performance
From: Vladimir Batov (Vladimir.Batov_at_[hidden])
Date: 2014-06-10 16:46:53
On 06/10/2014 11:43 PM, alex wrote:
>> Then I run
>> for (int k = 0; k < num_tries; ++k)
>> double cnv_time = performance::str_to_int(strings,
>> 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
>> 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 ?
I was surprised when you mentioned BOOST_ASSERT instead of BOOST_TEST.
Now I see that I redefined BOOST_TEST to BOOST_ASSERT temporarily... and
forgot to remove that. Thanks.
And indeed BOOST_ASSERT seems to be heavier than BOOST_TEST due to
expression-validity check done with
#define BOOST_TEST(expr) ((expr)? (void)0: ...)
simply checks the "expr". Will try tonight with gcc-4.8 and report back.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk