Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. General talk
  3. Qt 6
  4. Qt6 Windows slower than Qt6 Ubuntu
QtWS25 Last Chance

Qt6 Windows slower than Qt6 Ubuntu

Scheduled Pinned Locked Moved Solved Qt 6
ubuntuwindows 10 instmsvcgccqt6
47 Posts 5 Posters 7.6k Views
  • 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.
  • J Joe von Habsburg
    12 Feb 2024, 13:15

    I'm working on a project. I take data with GET request and use it. When I run my code, ubuntu faster than windows, 3 times.

    Qt version : 6.6.0
    Ubuntu compiler : gcc
    Ubuntu version : 22.04
    Windows compiler : MSVS2019
    Windows version : 10

    Is there any way, for get same speed ubuntu and windows ?

    J Online
    J Online
    JonB
    wrote on 12 Feb 2024, 13:36 last edited by JonB 2 Dec 2024, 13:37
    #3

    @Joe-von-Habsburg
    And in addition to @jsulm are you able to time how long each platform takes quite outside of a Qt program.? Could easily be a platform or whatever issue.
    (And btw make quite sure neither of your platform executables are compiled for debug/run under debug.)

    1 Reply Last reply
    0
    • J jsulm
      12 Feb 2024, 13:29

      @Joe-von-Habsburg You did not post any code, so nobody knows what exactly you're doing and how

      J Offline
      J Offline
      Joe von Habsburg
      wrote on 12 Feb 2024, 14:09 last edited by
      #4

      @jsulm

      This is my code for take data with get request.

      void DataReceiver::start()
      {
          _connection++;
          if(_connection > 1)
              return;
      
          qDebug() << "Starting take data";
          _takeData = true;
          while(_takeData){
              QDateTime time1 = QDateTime::currentDateTime();
              _sample = getData(54664);
              QDateTime time3 = QDateTime::currentDateTime();
              if(_takeIQData)
                  _iq = getData(54665);
              QDateTime time2 = QDateTime::currentDateTime();
              qDebug() << "sample : " << time3 - time1 << " iq : " << time2 - time3 << "time : " << time2 - time1;
              emit sendData(_sample, _iq);
          }
          qDebug() << "Finished taking data";
      }
      
      QByteArray DataReceiver::getData(int port)
      {
          QString url = QString("http://localhost:%1/sample").arg(port);
          QUrl apiUrl(url);
          QNetworkAccessManager manager;
          QNetworkRequest request(apiUrl);
          QNetworkReply *reply = manager.get(request);
          QEventLoop loop;
          connect(reply, &QNetworkReply::finished, &loop, &QEventLoop::quit);
          loop.exec();
          if (reply->error() == QNetworkReply::NoError) {
              QByteArray responseData = reply->readAll();
              return responseData;
              reply->deleteLater();
          } else {
              QString _error = tr("Error");
              QString _spectrum_error = tr("Spectrum error.");
              QMessageBox::critical(nullptr, _error, _spectrum_error);
              stop();
          }
          reply->deleteLater();
          return NULL;
      }
      
      J 1 Reply Last reply 12 Feb 2024, 14:34
      0
      • J Joe von Habsburg
        12 Feb 2024, 14:09

        @jsulm

        This is my code for take data with get request.

        void DataReceiver::start()
        {
            _connection++;
            if(_connection > 1)
                return;
        
            qDebug() << "Starting take data";
            _takeData = true;
            while(_takeData){
                QDateTime time1 = QDateTime::currentDateTime();
                _sample = getData(54664);
                QDateTime time3 = QDateTime::currentDateTime();
                if(_takeIQData)
                    _iq = getData(54665);
                QDateTime time2 = QDateTime::currentDateTime();
                qDebug() << "sample : " << time3 - time1 << " iq : " << time2 - time3 << "time : " << time2 - time1;
                emit sendData(_sample, _iq);
            }
            qDebug() << "Finished taking data";
        }
        
        QByteArray DataReceiver::getData(int port)
        {
            QString url = QString("http://localhost:%1/sample").arg(port);
            QUrl apiUrl(url);
            QNetworkAccessManager manager;
            QNetworkRequest request(apiUrl);
            QNetworkReply *reply = manager.get(request);
            QEventLoop loop;
            connect(reply, &QNetworkReply::finished, &loop, &QEventLoop::quit);
            loop.exec();
            if (reply->error() == QNetworkReply::NoError) {
                QByteArray responseData = reply->readAll();
                return responseData;
                reply->deleteLater();
            } else {
                QString _error = tr("Error");
                QString _spectrum_error = tr("Spectrum error.");
                QMessageBox::critical(nullptr, _error, _spectrum_error);
                stop();
            }
            reply->deleteLater();
            return NULL;
        }
        
        J Online
        J Online
        JonB
        wrote on 12 Feb 2024, 14:34 last edited by
        #5

        @Joe-von-Habsburg
        If you are calling this multiple times at least correct so as not to leak the QNetworkReply. Probably irrelevant, but just in case.

        How do timings compare on each platform quite outside of a Qt program?

        J J 2 Replies Last reply 12 Feb 2024, 14:45
        0
        • J JonB
          12 Feb 2024, 14:34

          @Joe-von-Habsburg
          If you are calling this multiple times at least correct so as not to leak the QNetworkReply. Probably irrelevant, but just in case.

          How do timings compare on each platform quite outside of a Qt program?

          J Offline
          J Offline
          Joe von Habsburg
          wrote on 12 Feb 2024, 14:45 last edited by
          #6

          @JonB
          I watch debug line and graphic. The data which is came, it's graphic data and I draw i it (drawing is 30ms).

          Debug line :

          qDebug() << "sample : " << time3 - time1 << " iq : " << time2 - time3 << "time : " << time2 - time1;
          

          In ubuntu : 150ms 0ms 150ms
          In windows : 400ms 0ms 400ms

          How can I take data with different way ? Can you give any example?

          Note: The data is come with only get request.

          J 1 Reply Last reply 12 Feb 2024, 14:47
          0
          • J Joe von Habsburg
            12 Feb 2024, 14:45

            @JonB
            I watch debug line and graphic. The data which is came, it's graphic data and I draw i it (drawing is 30ms).

            Debug line :

            qDebug() << "sample : " << time3 - time1 << " iq : " << time2 - time3 << "time : " << time2 - time1;
            

            In ubuntu : 150ms 0ms 150ms
            In windows : 400ms 0ms 400ms

            How can I take data with different way ? Can you give any example?

            Note: The data is come with only get request.

            J Online
            J Online
            JonB
            wrote on 12 Feb 2024, 14:47 last edited by
            #7

            @Joe-von-Habsburg
            I have suggested what you should test first, but you have said nothing each time.. I also suggested you do not test anything with the "debug" in "debug line and graphic".

            J 1 Reply Last reply 12 Feb 2024, 15:07
            0
            • J JonB
              12 Feb 2024, 14:47

              @Joe-von-Habsburg
              I have suggested what you should test first, but you have said nothing each time.. I also suggested you do not test anything with the "debug" in "debug line and graphic".

              J Offline
              J Offline
              Joe von Habsburg
              wrote on 12 Feb 2024, 15:07 last edited by
              #8

              @JonB I run release versions, and I saw same thing. Any advice for get request ? And is it possible, gcc more performance than msvc ?

              J 1 Reply Last reply 12 Feb 2024, 15:10
              0
              • J Joe von Habsburg
                12 Feb 2024, 15:07

                @JonB I run release versions, and I saw same thing. Any advice for get request ? And is it possible, gcc more performance than msvc ?

                J Online
                J Online
                JonB
                wrote on 12 Feb 2024, 15:10 last edited by JonB 2 Dec 2024, 15:10
                #9

                @Joe-von-Habsburg
                No, compiler is not going to make any difference when fetching data over a network and it's taking hundreds of milliseconds.

                J 1 Reply Last reply 12 Feb 2024, 15:18
                0
                • J JonB
                  12 Feb 2024, 15:10

                  @Joe-von-Habsburg
                  No, compiler is not going to make any difference when fetching data over a network and it's taking hundreds of milliseconds.

                  J Offline
                  J Offline
                  Joe von Habsburg
                  wrote on 12 Feb 2024, 15:18 last edited by
                  #10

                  @JonB

                  I wrote basic program just taking data. (Because I suspect other code lines slow me). I saw same output.

                  Can you give me code example for get request ?

                  1 Reply Last reply
                  0
                  • J JonB
                    12 Feb 2024, 14:34

                    @Joe-von-Habsburg
                    If you are calling this multiple times at least correct so as not to leak the QNetworkReply. Probably irrelevant, but just in case.

                    How do timings compare on each platform quite outside of a Qt program?

                    J Online
                    J Online
                    JonB
                    wrote on 12 Feb 2024, 15:27 last edited by
                    #11

                    @JonB said in Qt6 Windows slower than Qt6 Ubuntu:

                    How do timings compare on each platform quite outside of a Qt program?

                    J 1 Reply Last reply 12 Feb 2024, 15:30
                    0
                    • J JonB
                      12 Feb 2024, 15:27

                      @JonB said in Qt6 Windows slower than Qt6 Ubuntu:

                      How do timings compare on each platform quite outside of a Qt program?

                      J Offline
                      J Offline
                      Joe von Habsburg
                      wrote on 12 Feb 2024, 15:30 last edited by
                      #12

                      @JonB I watched graphic speed

                      J 1 Reply Last reply 13 Feb 2024, 06:13
                      0
                      • J Joe von Habsburg
                        12 Feb 2024, 15:30

                        @JonB I watched graphic speed

                        J Offline
                        J Offline
                        jsulm
                        Lifetime Qt Champion
                        wrote on 13 Feb 2024, 06:13 last edited by
                        #13

                        @Joe-von-Habsburg You should read more carefully what others write. What @JonB suggested is that you try to get the data with a non Qt application on both platforms to see whether the behaviour is the same or not...

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

                        J 1 Reply Last reply 13 Feb 2024, 07:03
                        0
                        • J jsulm
                          13 Feb 2024, 06:13

                          @Joe-von-Habsburg You should read more carefully what others write. What @JonB suggested is that you try to get the data with a non Qt application on both platforms to see whether the behaviour is the same or not...

                          J Offline
                          J Offline
                          Joe von Habsburg
                          wrote on 13 Feb 2024, 07:03 last edited by
                          #14

                          @jsulm I used javascript for get request.

                          const deneme = async() => {
                              while(true){
                                  var date1 = new Date();
                              
                                  var res = await fetch('http://localhost:54664/sample')
                                  var data = await res.json();
                                  console.log("sample len : ",data.samples[0].length)
                              
                                  var date2 = new Date();
                              
                                  var res2 = await fetch('http://localhost:54665/sample')
                                  var data2 = await res2.json();
                                  console.log("sample len : ",data2.samples[0].length)
                              
                                  var date3 = new Date();
                              
                                  console.log("sample : ", date2-date1, " - iq : ", date3 - date2, " - time : ", date3 - date1);
                              }
                          }
                          
                          
                          deneme();
                          

                          I saw same times between ubuntu and windows (90ms).
                          I think the problem is in windows Qt. Any idea ?

                          J 1 Reply Last reply 13 Feb 2024, 07:10
                          0
                          • J Joe von Habsburg
                            13 Feb 2024, 07:03

                            @jsulm I used javascript for get request.

                            const deneme = async() => {
                                while(true){
                                    var date1 = new Date();
                                
                                    var res = await fetch('http://localhost:54664/sample')
                                    var data = await res.json();
                                    console.log("sample len : ",data.samples[0].length)
                                
                                    var date2 = new Date();
                                
                                    var res2 = await fetch('http://localhost:54665/sample')
                                    var data2 = await res2.json();
                                    console.log("sample len : ",data2.samples[0].length)
                                
                                    var date3 = new Date();
                                
                                    console.log("sample : ", date2-date1, " - iq : ", date3 - date2, " - time : ", date3 - date1);
                                }
                            }
                            
                            
                            deneme();
                            

                            I saw same times between ubuntu and windows (90ms).
                            I think the problem is in windows Qt. Any idea ?

                            J Offline
                            J Offline
                            jsulm
                            Lifetime Qt Champion
                            wrote on 13 Feb 2024, 07:10 last edited by
                            #15

                            @Joe-von-Habsburg You should try to do your networking properly: without local event loops. Qt is asynchronous.

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

                            C 1 Reply Last reply 13 Feb 2024, 07:27
                            0
                            • J jsulm
                              13 Feb 2024, 07:10

                              @Joe-von-Habsburg You should try to do your networking properly: without local event loops. Qt is asynchronous.

                              C Online
                              C Online
                              Christian Ehrlicher
                              Lifetime Qt Champion
                              wrote on 13 Feb 2024, 07:27 last edited by
                              #16

                              ... And you should/must not recreate the QNetworkAcceesManager every time.

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

                              J 2 Replies Last reply 13 Feb 2024, 07:54
                              4
                              • C Christian Ehrlicher
                                13 Feb 2024, 07:27

                                ... And you should/must not recreate the QNetworkAcceesManager every time.

                                J Offline
                                J Offline
                                Joe von Habsburg
                                wrote on 13 Feb 2024, 07:54 last edited by
                                #17

                                @Christian-Ehrlicher said in Qt6 Windows slower than Qt6 Ubuntu:

                                And you should/must not recreate the QNetworkAcceesManager every time.

                                This work for me. Thank you so much :)

                                1 Reply Last reply
                                0
                                • C Christian Ehrlicher
                                  13 Feb 2024, 07:27

                                  ... And you should/must not recreate the QNetworkAcceesManager every time.

                                  J Offline
                                  J Offline
                                  Joe von Habsburg
                                  wrote on 13 Feb 2024, 13:45 last edited by
                                  #18

                                  @Christian-Ehrlicher

                                  I have another question. I received some times between ubuntu and windows (65ms). Everything is ok. But, sometimes windows rising 350ms for one packet. In ubuntu just max 80ms.

                                  QByteArray DataReceiver::getData(int port)
                                  {
                                      QString url = QString("http://localhost:%1/sample").arg(port);
                                      _apiUrl.setUrl(url);
                                      _request.setUrl(_apiUrl);
                                      _reply = _manager.get(_request);
                                      connect(_reply, &QNetworkReply::finished, &_loop, &QEventLoop::quit);
                                      _loop.exec();
                                      if (_reply->error() == QNetworkReply::NoError) {
                                          QByteArray responseData = _reply->readAll();
                                          _reply->deleteLater();
                                          return responseData;
                                      } else {
                                          QString _error = tr("Error");
                                          QString _spectrum_error = tr("Spectrum error.");
                                          QMessageBox::critical(nullptr, _error, _spectrum_error);
                                          stop();
                                      }
                                      _reply->deleteLater();
                                      return NULL;
                                  }
                                  

                                  Do you know, why it's rising ? What can I do another, after take data ?

                                  J 1 Reply Last reply 13 Feb 2024, 14:43
                                  0
                                  • J Joe von Habsburg
                                    13 Feb 2024, 13:45

                                    @Christian-Ehrlicher

                                    I have another question. I received some times between ubuntu and windows (65ms). Everything is ok. But, sometimes windows rising 350ms for one packet. In ubuntu just max 80ms.

                                    QByteArray DataReceiver::getData(int port)
                                    {
                                        QString url = QString("http://localhost:%1/sample").arg(port);
                                        _apiUrl.setUrl(url);
                                        _request.setUrl(_apiUrl);
                                        _reply = _manager.get(_request);
                                        connect(_reply, &QNetworkReply::finished, &_loop, &QEventLoop::quit);
                                        _loop.exec();
                                        if (_reply->error() == QNetworkReply::NoError) {
                                            QByteArray responseData = _reply->readAll();
                                            _reply->deleteLater();
                                            return responseData;
                                        } else {
                                            QString _error = tr("Error");
                                            QString _spectrum_error = tr("Spectrum error.");
                                            QMessageBox::critical(nullptr, _error, _spectrum_error);
                                            stop();
                                        }
                                        _reply->deleteLater();
                                        return NULL;
                                    }
                                    

                                    Do you know, why it's rising ? What can I do another, after take data ?

                                    J Offline
                                    J Offline
                                    Joe von Habsburg
                                    wrote on 13 Feb 2024, 14:43 last edited by
                                    #19

                                    @Joe-von-Habsburg I found the reason. Thanks a lot :) <3

                                    V 1 Reply Last reply 13 Feb 2024, 19:18
                                    0
                                    • J Joe von Habsburg
                                      13 Feb 2024, 14:43

                                      @Joe-von-Habsburg I found the reason. Thanks a lot :) <3

                                      V Offline
                                      V Offline
                                      Volker75
                                      wrote on 13 Feb 2024, 19:18 last edited by
                                      #20

                                      @Joe-von-Habsburg And what was the reason? Windows defender?

                                      J 1 Reply Last reply 14 Feb 2024, 07:46
                                      0
                                      • V Volker75
                                        13 Feb 2024, 19:18

                                        @Joe-von-Habsburg And what was the reason? Windows defender?

                                        J Offline
                                        J Offline
                                        Joe von Habsburg
                                        wrote on 14 Feb 2024, 07:46 last edited by Joe von Habsburg
                                        #21

                                        @Volker75 said in Qt6 Windows slower than Qt6 Ubuntu:

                                        And what was the reason? Windows defender?

                                        another networkmanager.....

                                        @Christian-Ehrlicher , @JonB , @jsulm

                                        Hi guys, I need your help. When I run the my program (only data receive) after 30min, my ram will be 20gb. It's increase always. I tested it in Ubuntu and Windows and I saw same thing. What should I do after take data?

                                        QByteArray DataReceiver::getData(int port)
                                        {
                                            QString url = QString("http://localhost:%1/sample").arg(port);
                                            _apiUrl.setUrl(url);
                                            _request.setUrl(_apiUrl);
                                            reply = _manager.get(_request);
                                            connect(reply, &QNetworkReply::finished, &_loop, &QEventLoop::quit);
                                            _loop.exec();
                                            if (reply->error() == QNetworkReply::NoError) {
                                                QByteArray responseData = reply->readAll();
                                                reply->deleteLater();
                                                return  responseData;
                                            } else {
                                                QString _error = tr("Error");
                                                QString _spectrum_error = tr("Spectrum error.");
                                                QMessageBox::critical(nullptr, _error, _spectrum_error);
                                                stop();
                                            }
                                            reply->deleteLater();
                                            return {};
                                        }
                                        

                                        if I use my code like that :

                                        QByteArray DataReceiver::getData(int port)
                                        {
                                            QString url = QString("http://localhost:%1/sample").arg(port);
                                            QUrl _apiUrl(url);
                                            QNetworkRequest _request(_apiUrl);
                                            QEventLoop _loop;
                                            QNetworkAccessManager _manager;
                                            QNetworkReply *reply = _manager.get(_request);
                                            connect(reply, &QNetworkReply::finished, &_loop, &QEventLoop::quit);
                                            _loop.exec();
                                            if (reply->error() == QNetworkReply::NoError) {
                                                QByteArray responseData = reply->readAll();
                                                reply->deleteLater();
                                                return  responseData;
                                            } else {
                                                QString _error = tr("Error");
                                                QString _spectrum_error = tr("Spectrum error.");
                                                QMessageBox::critical(nullptr, _error, _spectrum_error);
                                                stop();
                                            }
                                            reply->deleteLater();
                                            return {};
                                        }
                                        

                                        Memory will not rise but response time slow....

                                        J 1 Reply Last reply 14 Feb 2024, 08:44
                                        0
                                        • J Joe von Habsburg
                                          14 Feb 2024, 07:46

                                          @Volker75 said in Qt6 Windows slower than Qt6 Ubuntu:

                                          And what was the reason? Windows defender?

                                          another networkmanager.....

                                          @Christian-Ehrlicher , @JonB , @jsulm

                                          Hi guys, I need your help. When I run the my program (only data receive) after 30min, my ram will be 20gb. It's increase always. I tested it in Ubuntu and Windows and I saw same thing. What should I do after take data?

                                          QByteArray DataReceiver::getData(int port)
                                          {
                                              QString url = QString("http://localhost:%1/sample").arg(port);
                                              _apiUrl.setUrl(url);
                                              _request.setUrl(_apiUrl);
                                              reply = _manager.get(_request);
                                              connect(reply, &QNetworkReply::finished, &_loop, &QEventLoop::quit);
                                              _loop.exec();
                                              if (reply->error() == QNetworkReply::NoError) {
                                                  QByteArray responseData = reply->readAll();
                                                  reply->deleteLater();
                                                  return  responseData;
                                              } else {
                                                  QString _error = tr("Error");
                                                  QString _spectrum_error = tr("Spectrum error.");
                                                  QMessageBox::critical(nullptr, _error, _spectrum_error);
                                                  stop();
                                              }
                                              reply->deleteLater();
                                              return {};
                                          }
                                          

                                          if I use my code like that :

                                          QByteArray DataReceiver::getData(int port)
                                          {
                                              QString url = QString("http://localhost:%1/sample").arg(port);
                                              QUrl _apiUrl(url);
                                              QNetworkRequest _request(_apiUrl);
                                              QEventLoop _loop;
                                              QNetworkAccessManager _manager;
                                              QNetworkReply *reply = _manager.get(_request);
                                              connect(reply, &QNetworkReply::finished, &_loop, &QEventLoop::quit);
                                              _loop.exec();
                                              if (reply->error() == QNetworkReply::NoError) {
                                                  QByteArray responseData = reply->readAll();
                                                  reply->deleteLater();
                                                  return  responseData;
                                              } else {
                                                  QString _error = tr("Error");
                                                  QString _spectrum_error = tr("Spectrum error.");
                                                  QMessageBox::critical(nullptr, _error, _spectrum_error);
                                                  stop();
                                              }
                                              reply->deleteLater();
                                              return {};
                                          }
                                          

                                          Memory will not rise but response time slow....

                                          J Online
                                          J Online
                                          JonB
                                          wrote on 14 Feb 2024, 08:44 last edited by
                                          #22

                                          @Joe-von-Habsburg
                                          Is the difference due to the QNetworkAccessManager _manager; or to the QNetworkReply *reply = _manager.get(_request);?
                                          In the bad case you might connect to reply->destroyed() to make sure it is indeed getting freed.

                                          J 1 Reply Last reply 14 Feb 2024, 08:58
                                          0

                                          12/47

                                          12 Feb 2024, 15:30

                                          35 unread
                                          • Login

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