Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Saving data in a file is too slow
Forum Updated to NodeBB v4.3 + New Features

Saving data in a file is too slow

Scheduled Pinned Locked Moved Unsolved General and Desktop
14 Posts 6 Posters 2.1k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • jsulmJ jsulm

    @rahuman You could open the file once instead of opening it every time you want to write to it.

    R Offline
    R Offline
    rahuman
    wrote on last edited by
    #3

    @jsulm
    yes,I tried that also.But only 1 mb is increasing.

    JonBJ 1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #4

      Hi,

      What is the data volume ?
      What is the speed you expect ?
      What is your hard drive speed ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      R 1 Reply Last reply
      1
      • SGaistS SGaist

        Hi,

        What is the data volume ?
        What is the speed you expect ?
        What is your hard drive speed ?

        R Offline
        R Offline
        rahuman
        wrote on last edited by
        #5

        @SGaist
        Data volume : Using E(drive),Available space :350GB
        My required data size is 10GB to be download.
        Speed: Required 40 Mbyte/Sec
        Hard drive speed:7200 rpm(Toshiba 1 TB (DT01ACA100))

        Note:While doing Usb data transmission also i faced the same issue.But in python data is saving with the required speed.

        jsulmJ 1 Reply Last reply
        0
        • R rahuman

          @SGaist
          Data volume : Using E(drive),Available space :350GB
          My required data size is 10GB to be download.
          Speed: Required 40 Mbyte/Sec
          Hard drive speed:7200 rpm(Toshiba 1 TB (DT01ACA100))

          Note:While doing Usb data transmission also i faced the same issue.But in python data is saving with the required speed.

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #6

          @rahuman Did you check whether data transfer continues after 1MB?

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          R 1 Reply Last reply
          0
          • jsulmJ jsulm

            @rahuman Did you check whether data transfer continues after 1MB?

            R Offline
            R Offline
            rahuman
            wrote on last edited by
            #7

            @jsulm
            Yes,Continously i can recieve data, but with less speed.
            For ex: 1 Min it was reading 10Mb data

            jsulmJ 1 Reply Last reply
            0
            • R rahuman

              @jsulm
              Yes,Continously i can recieve data, but with less speed.
              For ex: 1 Min it was reading 10Mb data

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #8

              @rahuman And did you check that you are actually sending at 40MB/sec?

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              R 1 Reply Last reply
              0
              • jsulmJ jsulm

                @rahuman And did you check that you are actually sending at 40MB/sec?

                R Offline
                R Offline
                rahuman
                wrote on last edited by
                #9

                @jsulm
                No, i didn't check of sending speed .As of now i am just reading data.

                1 Reply Last reply
                0
                • R rahuman

                  @jsulm
                  yes,I tried that also.But only 1 mb is increasing.

                  JonBJ Offline
                  JonBJ Offline
                  JonB
                  wrote on last edited by
                  #10

                  @rahuman said in Saving data in a file is too slow:

                  @jsulm
                  yes,I tried that also.But only 1 mb is increasing.

                  I do not know what "But only 1 mb is increasing." might mean.

                  Please make 100% clear whether you are presently calling QFile::open() every time you get signal readyRead()/call readAll(), or not. Continually re-opening a file each time you want to append to it, for "small" chunks, is not optimal.

                  R 1 Reply Last reply
                  2
                  • JonBJ JonB

                    @rahuman said in Saving data in a file is too slow:

                    @jsulm
                    yes,I tried that also.But only 1 mb is increasing.

                    I do not know what "But only 1 mb is increasing." might mean.

                    Please make 100% clear whether you are presently calling QFile::open() every time you get signal readyRead()/call readAll(), or not. Continually re-opening a file each time you want to append to it, for "small" chunks, is not optimal.

                    R Offline
                    R Offline
                    rahuman
                    wrote on last edited by
                    #11

                    @JonB

                    1 Mb increasing means previously written like this.

                    QByteArray RxBuffer = socket->readAll();
                    qDebug() <<"Reading data......" <<RxBuffer;
                    QFile file ("C:/123.bin");
                    if(file.open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Text))
                    {
                    QTextStream out(&file);
                    out <<RxBuffer;
                    }

                    And changed like

                    QByteArray RxBuffer = socket->readAll();
                    qDebug() <<"Reading data......" <<RxBuffer;
                    QFile file ("C:/123.bin");
                    file.open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Text)
                    QTextStream out(&file);
                    out <<RxBuffer;

                    JonBJ 1 Reply Last reply
                    0
                    • R rahuman

                      @JonB

                      1 Mb increasing means previously written like this.

                      QByteArray RxBuffer = socket->readAll();
                      qDebug() <<"Reading data......" <<RxBuffer;
                      QFile file ("C:/123.bin");
                      if(file.open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Text))
                      {
                      QTextStream out(&file);
                      out <<RxBuffer;
                      }

                      And changed like

                      QByteArray RxBuffer = socket->readAll();
                      qDebug() <<"Reading data......" <<RxBuffer;
                      QFile file ("C:/123.bin");
                      file.open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Text)
                      QTextStream out(&file);
                      out <<RxBuffer;

                      JonBJ Offline
                      JonBJ Offline
                      JonB
                      wrote on last edited by
                      #12

                      @rahuman
                      This says nothing about 1MB, one way or the other.

                      If the second "changed like" is supposed to address "Continually re-opening a file each time you want to append to it", it does not.

                      1 Reply Last reply
                      2
                      • Christian EhrlicherC Offline
                        Christian EhrlicherC Offline
                        Christian Ehrlicher
                        Lifetime Qt Champion
                        wrote on last edited by
                        #13

                        Why do you use a QTextStream which converts your QByteArray into a QString and then back to a QByteArray (when it's written to disk). Simply using QFile::write() should be enough here.

                        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                        Visit the Qt Academy at https://academy.qt.io/catalog

                        1 Reply Last reply
                        5
                        • Kent-DorfmanK Offline
                          Kent-DorfmanK Offline
                          Kent-Dorfman
                          wrote on last edited by
                          #14

                          If you learn nothing else, understand that file IO speeds are not guaranteed. If is dependent upon the OS level IO your system supports, availaiblity of buffer/cache, and physical write speeds of the media. Waht happens when you compare the write speeds of rotational disk to an SSD and then to a ramdisk?...and like others said...don't open/close the file on every transaction

                          I light my way forward with the fires of all the bridges I've burned behind me.

                          1 Reply Last reply
                          2

                          • Login

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • Users
                          • Groups
                          • Search
                          • Get Qt Extensions
                          • Unsolved