Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Unordered output in application output panel of Qt Creator
Forum Updated to NodeBB v4.3 + New Features

Unordered output in application output panel of Qt Creator

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
3 Posts 2 Posters 437 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.
  • A Offline
    A Offline
    alainstgt
    wrote on last edited by alainstgt
    #1

    Qt 5.7 - Qt Creator 4.1.0 - MinGW 5.3 and VC++ 2015 - Windows 10 64-bits

    I get unordered output of my core application in the application output panel of Qt creator. If I define a console application, the output in the console is correct. See picture attached, where you can see the console output and the output panel of Qt Creator.
    Notice that I have this behaviour with both compilers mentioned above.
    Why is the output in the output panel not ordered? The application is running in one thread, see attached source code of main.

    // main.cpp
    
    #include <QCoreApplication>
    #include <QDebug>
    #include <iostream>
    #include "blumblumshub.h"
    #include "../../qutil/qutil.h"
    #include "../../benchmark/benchmark.h"
    #include "../../mersenne/mersenne/mersenne.h"
    
    using namespace std;
    bool BENCHMARK = true;
    
    int main(int argc, char *argv[])
    {
        QCoreApplication app(argc, argv);
    
        qDebug() << "sizeof(int):" << sizeof(int) << "  sizeof(void*):" << sizeof(void*);
    
        qDebug() << "\n=== testing BBS ===";
        int P = 7;
        int Q = 19;
        int seed = 4;
        qDebug() << "p:" << P << "   q:" << Q << "   seed:" << seed;
    
        BBS numberGen(P, Q, seed);
    
        //generate 10 random numbers
        for (int i = 0; i < 10; i++)
        {
            cout << numberGen.getRandNum() << " ";
        }
        cout << endl;
    
        //generate 10 random bits
        for (int i = 0; i < 10; i++)
        {
            cout << numberGen.getRandBit() << " ";
        }
        cout << endl;
    
        ///////////////////////////////////////////////////////////////////////////
    
        P = 1;
        Q = 100;
        seed = 1;
        qDebug() << "\n=== testing blumblumshub ===";
        BlumBlumShub generator( P, Q, seed );
        //generate 10 random numbers
        for (int i = 0; i < 10; i++)
            cout << generator.getNum() << " ";
        cout << endl;
    
        //generate 10 random bits
        for (int i = 0; i < 10; i++)
            cout << generator.getBit() << " ";
        cout << endl;
    
        //--------------------------------- 64 bits -------------------------------
    
        qDebug() << "\n=== testing blumblumshub 64 bits ===";
        BlumBlumShub64 generator64( P, Q, seed );
    
        //generate 10 random numbers
        for (int i = 0; i < 10; i++)
            cout << generator64.getNum() << " ";
        cout << endl;
    
        //generate 10 random bits
        for (int i = 0; i < 10; i++)
            cout << generator64.getBit() << " ";
        cout << endl;
    
        // ----- with big data now ------
        qDebug() << "----- testing big numbers -----";
        generator64.setParams(123456789, 2345678, 3456789);
    
        //generate 10 random numbers
        for (int i = 0; i < 10; i++)
            cout << generator64.getNum() << " ";
        cout << endl;
    
        //generate 10 random bits
        for (int i = 0; i < 10; i++)
            cout << generator64.getBit() << " ";
        cout << endl;
    
        // benchmark
    
        unsigned loops = 100000;
        uint32_t sum32 = 0;
        uint64_t sum64 = 0;
        Mersenne mersenne(123);
        Mersenne64 mersenne64(123);
    
        Benchmark bm;
        bm.init();
    
        for ( unsigned i = 0; i < loops; ++i )
            sum32 += generator.getNum();
        bm.getMark( "blumblumshub" );
    
        for ( unsigned i = 0; i < loops; ++i )
            sum64 += generator64.getNum();
        bm.getMark( "blumblumshub64" );
    
        for ( unsigned i = 0; i < loops; ++i )
            sum32 += mersenne();
        bm.getMark( "mersenne" );
    
        for ( unsigned i = 0; i < loops; ++i )
            sum64 += mersenne64();
        bm.getMark( "mersenne64" );
    
    
        QString title = compilerInfo() + "\n - output of " + numberWithThousandsSeparator(loops) + " random numbers -";
        bm.dump( title, false);
    
    
        return app.exec();
    }
    
    ![blumblumshub_output.png](https://ddgobkiprc33d.cloudfront.net/ec0bc96c-1f4f-45ee-ad34-b2cd6a18bf1f.png)
    aha_1980A 1 Reply Last reply
    0
    • A alainstgt

      Qt 5.7 - Qt Creator 4.1.0 - MinGW 5.3 and VC++ 2015 - Windows 10 64-bits

      I get unordered output of my core application in the application output panel of Qt creator. If I define a console application, the output in the console is correct. See picture attached, where you can see the console output and the output panel of Qt Creator.
      Notice that I have this behaviour with both compilers mentioned above.
      Why is the output in the output panel not ordered? The application is running in one thread, see attached source code of main.

      // main.cpp
      
      #include <QCoreApplication>
      #include <QDebug>
      #include <iostream>
      #include "blumblumshub.h"
      #include "../../qutil/qutil.h"
      #include "../../benchmark/benchmark.h"
      #include "../../mersenne/mersenne/mersenne.h"
      
      using namespace std;
      bool BENCHMARK = true;
      
      int main(int argc, char *argv[])
      {
          QCoreApplication app(argc, argv);
      
          qDebug() << "sizeof(int):" << sizeof(int) << "  sizeof(void*):" << sizeof(void*);
      
          qDebug() << "\n=== testing BBS ===";
          int P = 7;
          int Q = 19;
          int seed = 4;
          qDebug() << "p:" << P << "   q:" << Q << "   seed:" << seed;
      
          BBS numberGen(P, Q, seed);
      
          //generate 10 random numbers
          for (int i = 0; i < 10; i++)
          {
              cout << numberGen.getRandNum() << " ";
          }
          cout << endl;
      
          //generate 10 random bits
          for (int i = 0; i < 10; i++)
          {
              cout << numberGen.getRandBit() << " ";
          }
          cout << endl;
      
          ///////////////////////////////////////////////////////////////////////////
      
          P = 1;
          Q = 100;
          seed = 1;
          qDebug() << "\n=== testing blumblumshub ===";
          BlumBlumShub generator( P, Q, seed );
          //generate 10 random numbers
          for (int i = 0; i < 10; i++)
              cout << generator.getNum() << " ";
          cout << endl;
      
          //generate 10 random bits
          for (int i = 0; i < 10; i++)
              cout << generator.getBit() << " ";
          cout << endl;
      
          //--------------------------------- 64 bits -------------------------------
      
          qDebug() << "\n=== testing blumblumshub 64 bits ===";
          BlumBlumShub64 generator64( P, Q, seed );
      
          //generate 10 random numbers
          for (int i = 0; i < 10; i++)
              cout << generator64.getNum() << " ";
          cout << endl;
      
          //generate 10 random bits
          for (int i = 0; i < 10; i++)
              cout << generator64.getBit() << " ";
          cout << endl;
      
          // ----- with big data now ------
          qDebug() << "----- testing big numbers -----";
          generator64.setParams(123456789, 2345678, 3456789);
      
          //generate 10 random numbers
          for (int i = 0; i < 10; i++)
              cout << generator64.getNum() << " ";
          cout << endl;
      
          //generate 10 random bits
          for (int i = 0; i < 10; i++)
              cout << generator64.getBit() << " ";
          cout << endl;
      
          // benchmark
      
          unsigned loops = 100000;
          uint32_t sum32 = 0;
          uint64_t sum64 = 0;
          Mersenne mersenne(123);
          Mersenne64 mersenne64(123);
      
          Benchmark bm;
          bm.init();
      
          for ( unsigned i = 0; i < loops; ++i )
              sum32 += generator.getNum();
          bm.getMark( "blumblumshub" );
      
          for ( unsigned i = 0; i < loops; ++i )
              sum64 += generator64.getNum();
          bm.getMark( "blumblumshub64" );
      
          for ( unsigned i = 0; i < loops; ++i )
              sum32 += mersenne();
          bm.getMark( "mersenne" );
      
          for ( unsigned i = 0; i < loops; ++i )
              sum64 += mersenne64();
          bm.getMark( "mersenne64" );
      
      
          QString title = compilerInfo() + "\n - output of " + numberWithThousandsSeparator(loops) + " random numbers -";
          bm.dump( title, false);
      
      
          return app.exec();
      }
      
      ![blumblumshub_output.png](https://ddgobkiprc33d.cloudfront.net/ec0bc96c-1f4f-45ee-ad34-b2cd6a18bf1f.png)
      aha_1980A Offline
      aha_1980A Offline
      aha_1980
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi @alainstgt,

      it seems you mix qDebug and cout. Both might use buffering, so the output is interleaved in Creator. The same can happen if you have output to both stdout and stderr.

      Regards

      Qt has to stay free or it will die.

      A 1 Reply Last reply
      2
      • aha_1980A aha_1980

        Hi @alainstgt,

        it seems you mix qDebug and cout. Both might use buffering, so the output is interleaved in Creator. The same can happen if you have output to both stdout and stderr.

        Regards

        A Offline
        A Offline
        alainstgt
        wrote on last edited by
        #3

        @aha_1980
        Thanks for your hint.
        cout still doesn't work correctly, even when not mixed with qDebug(), see picture attached
        blumblumshub_cout.png

        1 Reply Last reply
        0

        • Login

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