[Development] QStringRef conversion functions

Girish Ramakrishnan girish at forwardbias.in
Wed Jun 13 22:03:23 CEST 2012


Hi Keith,
Yes, it makes sense to add QStringRef::toInt/Float/Double. The entire
point of QStringRef was to make things faster and having those apis
will definitely be an improvement.

Girish

On Wed, Jun 13, 2012 at 12:24 PM, Keith Gardner
<kgardner at zebraimaging.com> wrote:
> Sorry to backtrack this thread, but I have some performance information.  Just FYI, I haven't made any code changes to Qt, yet.
>
> To give some background information, I am parsing a single xml file with 88,704 floating point values using the QXmlStreamReader.  I am running in Windows 7 x64 and am using an SSD to store the file.  My compiler is Visual Studio 2010 with a Win32 configuration.
>
> I would take the QStringRef for the argument, convert it to a string using the toString() function and then use toFloat().
>
>        This method would parse the entire document in 608 milliseconds in release mode.
>                stringRef.toString().toFloat()
>        Changing that code to use wcstod on the QStringRef resulted in parsing the document in 467 millesconds.
>                wcstod((const wchar_t*)stringref.unicode(),0);
>
> In debug mode, this goes from 2814 milliseconds down to 1850 milliseconds.
>
> I would say that there is a big payout with changing what we currently have.
>
> Thanks,
> Keith
>
> -----Original Message-----
> From: Girish Ramakrishnan [mailto:girish at forwardbias.in]
> Sent: Monday, June 11, 2012 4:55 PM
> To: Keith Gardner
> Cc: development at qt-project.org
> Subject: Re: [Development] QStringRef conversion functions
>
> Hi,
>
> On Mon, Jun 11, 2012 at 11:38 AM, Keith Gardner
> <kgardner at zebraimaging.com> wrote:
>> I was wondering if there would be a possibility of getting some of the
>> conversion functions that are in QString implemented in QStringRef (toInt,
>> toFloat, etc...).  The reasoning behind this is that I am using the
>> QXMLStreamReader to parse an XML file with over 88,704 floating point
>> values.  I am trying to improve the speed at which the file is parsed and I
>> believe one of the bottlenecks is taking an attribute of QStringRef and
>> copying its data into a QString in order to convert to a float.  I would
>> prefer that the copy never happen but that would require some more
>> intelligence be added into the QStringRef class.
>>
>
> I am tempted to say it's 5.1 material but it would be nice to see how
> much gains you are getting out of these new apis and how intrusive the
> new code is. Can you push your change to gerrit ?
>
> Thanks,
> Girish



More information about the Development mailing list