Boost logo

Boost Users :

Subject: [Boost-users] lexical_cast between double and string slow in Visual Studio 2013
From: David Roberts (dave_at_[hidden])
Date: 2014-03-24 07:05:02


In Boost 1.54 I have noticed that lexical_cast from double to string and back is much slower in Visual Studio 2013 (Visual C++ 12) than it was in Visual Studio 2010 (Visual C++ 10).

The following test program demonstrates the problem:

#include <boost/lexical_cast.hpp>
#include <string>

int main (int, char **)
{
    for (double count = 0.0; count < 1000000.0; count += 1.41)
    {
        std::string result(boost::lexical_cast<std::string>(count));
        count = boost::lexical_cast<double>(result);
    }

    return 0;
}

It can be built at the Visual Studio command prompt using:

cl /O2 /EHsc /DNDEBUG /I\some\path\boost-1_54 lexcast.cpp

to give the program lexcast.exe. When built with Visual Studio 2013 this program takes about 10 seconds to run on my machine. When built with Visual Studio 2010 it takes about 3 seconds.

Is this already a known issue? If not I can do a bit more investigation to narrow down why it's so much slower, but I don't want to waste my time if this has already been done.

Thanks,

David


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net