$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
Subject: Re: [boost] [lexical_cast] Fast conversion from boost::iterator_range<std::string::iterator>?
From: Thomas Heller (thom.heller_at_[hidden])
Date: 2011-11-23 17:24:44
On 11/23/2011 04:15 PM, Matthew Chambers wrote:
> On 11/23/2011 4:13 PM, Matthew Chambers wrote:
>> I put together a test (http://codepad.org/lKxMXOwP):
>>
>> 1000000 iterations of "123":
>> atoi: 0.0695092 seconds
>> strtol: 0.0652839 seconds
>> Spirit: 0.546789 seconds
>> lexical_cast(string): 0.615594 seconds
>> lexical_cast(iterator_range): 4.25534 seconds
>> lexical_cast(iterator_range->string): 1.07405 seconds
>>
>> 1000000 iterations of "123567890":
>> atoi: 0.0856611 seconds
>> strtol: 0.0829571 seconds
>> Spirit: 0.905017 seconds
>> lexical_cast(string): 0.762137 seconds
>> lexical_cast(iterator_range): 7.46185 seconds
>> lexical_cast(iterator_range->string): 1.23397 seconds
>>
>> 1000000 iterations of "1.23456":
>> atof: 0.520452 seconds
>> strtod: 0.519113 seconds
>> Spirit: 1.02579 seconds
>> lexical_cast(string): 2.93515 seconds
>> lexical_cast(iterator_range): 6.62648 seconds
>> lexical_cast(iterator_range->string): 3.73831 seconds
>>
>> 1000000 iterations of "1.23456789e42":
>> atof: 0.711819 seconds
>> strtod: 0.719144 seconds
>> Spirit: 1.48992 seconds
>> lexical_cast(string): 3.31997 seconds
>> lexical_cast(iterator_range): 9.87004 seconds
>> lexical_cast(iterator_range->string): 4.20932 seconds
>
> I forgot to say the test environment:
> boost 1.47
> MSVC 9 SP1
> Core 2 Q9400
>
> -Matt
The spirit code isn't really optimal (see the slightly improved version
attached). Also, did you turn on optimization?