Boost logo

Boost :

Subject: Re: [boost] Boost.Convert. Take 2.
From: Rob Stewart (robertstewart_at_[hidden])
Date: 2014-02-20 21:06:05


On February 20, 2014 6:27:42 PM EST, Vladimir Batov <Vladimir.Batov_at_[hidden]> wrote:
>On 02/21/2014 08:31 AM, Edward Diener wrote:
>> On 2/16/2014 3:56 PM, Vladimir Batov wrote:
>
>> I think you have successfully focused on what is needed for a more
>> flexible lexical_cast-like version this time.
>>
>
>I am especially surprised by the fact that its performance seems quite
>adequate (without any optimization):
[snip]
>tests. On the other hand the test could not be any more
>straightforward:
>
> double p4 = clock();
>
> for (int k = 0; k < local::num_cycles; ++k)
> sscanf("12345", "%d", &v);
>
> double p5 = clock();
>
> for (int k = 0; k < local::num_cycles; ++k)
> boost::lexical_cast<int>("12345");
>
> double p6 = clock();
>
> for (int k = 0; k < local::num_cycles; ++k)
> boost::convert<int>::from("12345", ccnv).value();
>
> double p7 = clock();
>
> printf("scanf/lcast/convert=%.2f/%.2f/%.2f seconds.\n",
> (p5 - p4) / CLOCKS_PER_SEC,
> (p6 - p5) / CLOCKS_PER_SEC,
> (p7 - p6) / CLOCKS_PER_SEC);

I assume you're timing an optimized build, on which case you are being misled by the optimizer because you're not using the results of the conversions.

___
Rob

(Sent from my portable computation engine)


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