Results 1 to 9 of 9

Thread: Performance of QDataStream

  1. #1
    Join Date
    Oct 2009
    Location
    Germany
    Posts
    13
    Qt products
    Qt4
    Platforms
    Windows

    Default Performance of QDataStream

    Hi all,

    i would like to know if somebody knows about how fast QDataStream can write into a file?
    ( in MByte / second )

    Qt Code:
    1. QFile file("test.txt");
    2. QDataStream out(&file);
    3. out.setByteOrder(QDataStream::LittleEndian);
    4. file.open(QIODevice::WriteOnly);
    5.  
    6. QString s = "";
    7.  
    8. // 8mb string
    9. for(int i = 0; i < 8388608; i++)
    10. {
    11. s.append("o");
    12. }
    13.  
    14. QByteArray b = s.toLocal8Bit();
    15.  
    16. // writing 1GB data in the file
    17. for(int i = 0; i < 256; i++)
    18. {
    19. out << b
    20.  
    21. }
    To copy to clipboard, switch view to plain text mode 

    in this test i get a datarate of ~90 MByte/sec.

    Is there any way to improve the speed or has anybody information about QDataStream's speed?

    Thanks

  2. #2
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Performance of QDataStream

    Try to use one of QDataStream::write methods.

  3. #3
    Join Date
    Oct 2009
    Location
    Germany
    Posts
    13
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Performance of QDataStream

    i tried that, it's the same speed...

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Performance of QDataStream

    Quote Originally Posted by drizzt View Post
    in this test i get a datarate of ~90 MByte/sec.

    Is there any way to improve the speed or has anybody information about QDataStream's speed?
    This result is probably incorrect. You forget there is buffering involved. How do you measure the speed anyway?

    By the way, 90MBps is 720Mbps which is almost one gigabit per second, I doubt your disk is that fast.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Oct 2009
    Location
    Germany
    Posts
    13
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Performance of QDataStream

    i started a timer before i run the second for-loop and get the time bye t.elapsed() ...

    so 1gb of data takes a time of ~11seconds.

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Performance of QDataStream

    Quote Originally Posted by drizzt View Post
    so 1gb of data takes a time of ~11seconds.
    Wrong. There is more data there as the byte array is serialized. And everything goes through a buffer which means you know exactly nothing about speed of QDataStream.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    Oct 2009
    Location
    Germany
    Posts
    13
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Performance of QDataStream

    Wrong. There is more data there as the byte array is serialized. And everything goes through a buffer which means you know exactly nothing about speed of QDataStream.
    That was the question at the beginning of this question: how fast can i write data on disk?
    I'm not the real expert, so i tried a lot of things.

    what i can say now is, that after the second for-loop, in 11-12seconnds, i have a file on disk which is exackty 1GB.

    You say thats wrong, what would you do?

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Performance of QDataStream

    Quote Originally Posted by drizzt View Post
    That was the question at the beginning of this question: how fast can i write data on disk?
    That depends on the disk.

    what i can say now is, that after the second for-loop, in 11-12seconnds, i have a file on disk which is exackty 1GB.
    You mean "1073741824 bytes" or "1GB"? If the latter then it's not 1GB, it's "about 1GB".

    You say thats wrong, what would you do?
    I wouldn't measure QDataStream performance. And if I really wanted to, then I wouldn't do it with a disk-based QIODevice underneath and I'd turn off all the buffering I could.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  9. #9
    Join Date
    Oct 2009
    Location
    Germany
    Posts
    13
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Performance of QDataStream

    1Gb = 1024 x 1024 x 1024 bytes yes

    also what you want to say is: Qt can write data on disk as fast as my disk is?
    If it works like it do in my example, its enough for my problem, which i have to solve.

Similar Threads

  1. QDataStream and saving and loading QList
    By Noxxik in forum Qt Programming
    Replies: 3
    Last Post: 1st March 2009, 22:02
  2. QT core lib performance?
    By Quentin in forum Qt Programming
    Replies: 1
    Last Post: 31st January 2009, 09:17
  3. Performance Issues in Qt-4.4.3 / Qwt-5.1.1
    By swamyonline in forum Qt Programming
    Replies: 2
    Last Post: 25th January 2009, 17:50
  4. Qt4 poor printing performance
    By seneca in forum Qt Programming
    Replies: 4
    Last Post: 22nd January 2009, 14:23
  5. QDataStream >> QString
    By smalls in forum Qt Programming
    Replies: 2
    Last Post: 17th January 2006, 22:14

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.