Results 1 to 15 of 15

Thread: QHttp::dataSendProgress transfer speed Kb sec.

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default QHttp::dataSendProgress transfer speed Kb sec.

    I mesure the time wo file upload go up on send process....

    void QHttp::dataSendProgress ( int done, int total ) [signal]
    Warning: done and total are not necessarily the size in bytes, since for large files these values might need to be "scaled" to avoid overflow.
    is this Byte or bit done???? or random nummer to only qscrollbar

    or better use qint64 QHttp::read ( char * data, qint64 maxlen ) ?

    gostart.start();
    /* header set QTime gostart; gostart.start(); */
    uint mmse = gostart.elapsed(); /* millisecond*/

    to become speed ...... kb sec how i must calc i have time && size...?


    float kilobite = bytesRead * 8;
    float speedwork = kilobite / mmse;

    or

    float speedwork = bytesRead / mmse;




    if i but BiteorMega( incomming done QHttp::dataSendProgress ) direct the ammount of MB is correct .....


    and i mesure time && MB so......
    Qt Code:
    1. QString TimeaGo( int ms , int sek )
    2. {
    3. QString elapstime;
    4. QString elapettime,ssec,smin,shor,speeder;
    5. int sec_el;
    6.  
    7. if (ms > 0) {
    8. sec_el = ms / 1000;
    9. }
    10.  
    11. if (sek > 0) {
    12. sec_el = sek;
    13. }
    14.  
    15. if (ms < 1 && sek < 1) {
    16. return elapstime;
    17. }
    18.  
    19.  
    20.  
    21. int min_el = 0;
    22. int hor_el = 0;
    23. int timebreak = 0;
    24. for (int i = 0; i < sec_el; ++i) {
    25. timebreak++;
    26. if (timebreak == 60) {
    27. timebreak = 0;
    28. min_el++;
    29. }
    30. if (min_el == 60) {
    31. min_el = 0;
    32. hor_el++;
    33. }
    34. if (hor_el == 24) {
    35. hor_el = 0;
    36. /* day 1 */
    37. }
    38.  
    39. }
    40.  
    41. if (timebreak < 10) {
    42. ssec = QString("0%1").arg(timebreak);
    43. } else {
    44. ssec = QString("%1").arg(timebreak);
    45. }
    46. if (min_el < 10) {
    47. smin = QString("0%1").arg(min_el);
    48. } else {
    49. smin = QString("%1").arg(min_el);
    50. }
    51. if (hor_el < 10) {
    52. shor = QString("0%1").arg(hor_el);
    53. } else {
    54. shor = QString("%1").arg(hor_el);
    55. }
    56.  
    57. elapstime = QString("%1:%2:%3").arg(shor).arg(smin).arg(ssec);
    58. return elapstime;
    59. }
    60.  
    61.  
    62. QString BiteorMega( int peso )
    63. {
    64.  
    65. /*
    66. on Byte are 8 bit
    67. on Kilobyte are 1024 Byte.
    68. */
    69.  
    70. QString humanread;
    71. double canno = peso / 1024;
    72. int sale = canno;
    73. if (peso > 0) {
    74. if (canno < 1) {
    75. sale = 1;
    76. }
    77. }
    78.  
    79. if (sale < 1025) {
    80. humanread = QString("KB %1").arg(sale);
    81. return humanread;
    82. }
    83.  
    84. float megad = sale / 1024;
    85.  
    86. if (megad < 1025) {
    87. humanread = QString("MB %1").arg(megad);
    88. return humanread;
    89. } else {
    90. /* maybe impossibel upload GBs */
    91. humanread = QString("GB 1+");
    92. }
    93.  
    94. return humanread;
    95. }
    To copy to clipboard, switch view to plain text mode 

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

    Default Re: QHttp::dataSendProgress transfer speed Kb sec.

    What is the actual question?
    For relatively short files the progress will be measured in bytes, but you can't rely on that to be always the case, as for example file sizes larger than 2GB can't be stored with ints, so in that case the result will be scaled.

  3. #3
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QHttp::dataSendProgress transfer speed Kb sec.

    Quote Originally Posted by wysota View Post
    What is the actual question?
    For relatively short files the progress will be measured in bytes, but you can't rely on that to be always the case, as for example file sizes larger than 2GB can't be stored with ints, so in that case the result will be scaled.
    I suppose http://doc.trolltech.com/4.2/qiodevice.html#pos
    have moore precision on uload??? or is this mistake?

    QFile * locfile
    BeamUpFile = locfile;
    QFileInfo info(locfile);
    qint64 filezsize = info.size();
    qint64 filereadnow = BeamUpFile->pos();

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

    Default Re: QHttp::dataSendProgress transfer speed Kb sec.

    This only works for random access devices. A socket is not a random access device.

  5. #5
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QHttp::dataSendProgress transfer speed Kb sec.

    Quote Originally Posted by wysota View Post
    This only works for random access devices. A socket is not a random access device.
    Hmmm... and How to become the corect size read status? on upload?

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

    Default Re: QHttp::dataSendProgress transfer speed Kb sec.

    Either calculate it yourself or use the progress signals regardless of their precision.

  7. #7
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QHttp::dataSendProgress transfer speed Kb sec.

    Quote Originally Posted by wysota View Post
    Either calculate it yourself or use the progress signals regardless of their precision.
    qint64 filereadnow = BeamUpFile->pos(); /* pointer to qfile upload qt4.2 */
    work perfekt i tested on a iso file upload 698MB on my LAN
    result ... http://qt-webdav.svn.sourceforge.net....h?view=markup

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

    Default Re: QHttp::dataSendProgress transfer speed Kb sec.

    Have you taken into consideration that the size pos() returns doesn't mean the position of the stream being sent but rather the one being read from the file? There is also some amount of data that is currently buffered along the way (file buffer, socket buffer, system buffer, NIC buffer, possibly more).

  9. #9
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QHttp::dataSendProgress transfer speed Kb sec.

    Quote Originally Posted by wysota View Post
    Have you taken into consideration that the size pos() returns doesn't mean the position of the stream being sent but rather the one being read from the file? There is also some amount of data that is currently buffered along the way (file buffer, socket buffer, system buffer, NIC buffer, possibly more).

    I suppose QIODevice read fast or not fast in to speed tat socket can send....
    on dataSendProgress(int done , int) on done is 3% the same value as QIODevice :: pos() at end is the same .... but QIODevice :: pos() go moore as 2GB....


    And How calculate you the Time to complete upload? && Speed?

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

    Default Re: QHttp::dataSendProgress transfer speed Kb sec.

    Quote Originally Posted by patrik08 View Post
    And How calculate you the Time to complete upload? && Speed?
    speed = (length*percentage_completed) / time_elapsed
    time remaining = (1 - percentage_completed) * length/speed or 100*(1-percentage_completed)*time_elapsed
    percentage_completed = done/total (taken from QHttp progress signals)

    division used here (/) is a floating point operator.

    Example:

    length = 1000000B
    time_elapsed = 5s
    done = 1000
    total = 100000

    hence:
    percentage_completed = 0.01 (=10000B)
    speed = (10^6*10^-2)/5s = 10000/5 = 2000B/s
    time remaining = (1-0.01) * 10^6/2000 = 0.99 * 500 = 495s
    time remaining (alternative) = 100 * 0.99 * 5 = 99 * 5 = 495s


    BTW. 1% * 3GB = 3MB - buffers are not that large therefore you won't notice a difference with such big values here. But if you try sending a small file (100kB) through an extremely slow link, the file read buffer and socket write buffer positions might be quite different.

  11. #11
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QHttp::dataSendProgress transfer speed Kb sec.

    Quote Originally Posted by wysota View Post
    speed = (length*percentage_completed) / time_elapsed

    division used here (/) is a floating point operator.
    different.
    double can go to .arg(22.22) or accept .arg float as double?
    not run....
    QString str = QString("speed Kb/s: %1").arg(d, 0, 'f', 0);

    How can .arg() print only 2 decimal??
    QChar & fillChar 0

    Qt Code:
    1. double d = 12.34;
    2. QString str = QString("delta: %1").arg(d, 0, 'E', 3);
    3. // str == "delta: 1.234E+01"
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. transfer large files using qsocket
    By vishesh in forum Qt Programming
    Replies: 3
    Last Post: 2nd March 2007, 15:40
  2. Speed of static app
    By jcr in forum Qt Programming
    Replies: 1
    Last Post: 6th October 2006, 20:09
  3. How to get qtdemo with reasonable speed?
    By ponto in forum General Discussion
    Replies: 8
    Last Post: 31st May 2006, 10:25
  4. Speed penalty when using RTTI?
    By pir in forum General Programming
    Replies: 5
    Last Post: 19th May 2006, 00:36
  5. A way to transfer info from .pro to Makefile
    By thawkins in forum Qt Programming
    Replies: 3
    Last Post: 2nd May 2006, 21:06

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.