Results 1 to 15 of 15

Thread: Writing numbers to file fast! (Need Faster float to char implementation)

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2008
    Posts
    73
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    11
    Thanked 7 Times in 3 Posts

    Default Writing numbers to file fast! (Need Faster float to char implementation)

    Hi guys, I'd appreciate any insight you have on this.

    What I am doing is capturing data from a data acquisition card working at 200kS/s and saving the data into a double array. Unfortunately I cannot save the data to file before the next lot of data comes in, so I have resorted to saving 30 seconds worth (the largest amount that would fit in my memory) to RAM and then saving it to disk. Its not ideal.

    UPDATE: ________________________
    I have found that most of the time is spent converting the various types into a qbytearray. So I think my question has changed, how can I convert a float (or at worst an int) into a qbytearray (or string) quicker than QString::number or QTextStream << does. Thanks.
    ________________________________

    What I then need to do then is save it to a file. So far I have been using the various QString and QTextStream implementations of "float to string" to find that they take a huge amount of time. Much, much slower than the actual writing to the hard drive (which I thought would be the limiting factor).

    So I decided to do some tests and I found that even writing text to a file (using qtextstream) is pretty slow (note: in a loop). For a float it takes 24 seconds, for a QByteArray with 9 characters it takes 15.7 seconds.

    Now only appending the data to a QByteArray to make one huge array, then writing only takes 3 seconds for a char array but 48s for the float!!! And 24 seconds for an int.

    So, down to business, does anyone know how I could write to a file? I'm willing to try anything, so long as its within my fairly limited programming knowledge.
    Last edited by philwinder; 4th December 2008 at 14:46. Reason: Information update
    Best Regards,
    Phil Winder
    www.philwinder.com

Similar Threads

  1. qt-3.3.8 fail in scratchbox
    By nass in forum Installation and Deployment
    Replies: 0
    Last Post: 25th May 2007, 15:21
  2. fast writing of large amounts of data to files
    By TheKedge in forum Qt Programming
    Replies: 1
    Last Post: 13th February 2007, 16:33
  3. Writing a XML file
    By Djony in forum Qt Programming
    Replies: 7
    Last Post: 5th February 2007, 16:23
  4. Writing to file at specific
    By safknw in forum Qt Programming
    Replies: 3
    Last Post: 1st December 2006, 11:12
  5. XML file writing
    By mbjerkne in forum Qt Programming
    Replies: 2
    Last Post: 24th May 2006, 19:04

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.