Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

    Application slow on the first run, then speed is ok

    General and Desktop
    speed
    3
    6
    1592
    Loading More Posts
    • 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.
    • R
      reezeus last edited by

      Hi there

      I have a GUI Qt application that works ok. When clicking on one button, I launch a very heavy function (in terms of consuming) as there are multiple sql query, excel opening/closing and file writing in each iteration of a single loop.
      When I start the app for the first time of the day and click the button, it takes about 20 mins to run. Then if I re-run it, it takes less than 2 mins (even if I re-run it 50 times). I mention that the function does exactly the same thing every time it is launched (there is nothing like "if this is has already been done today, then just update...")
      Could you please help me with this issue? Basically I will be very happy if I can run it in two mins when I launch it for the first time of the day.
      Thanks for taking the time to read.

      Reezeus

      K 1 Reply Last reply Reply Quote 0
      • K
        koahnig @reezeus last edited by

        @reezeus
        Hi and welcome to devnet

        This sounds like a buffering issue, but is not related to Qt.

        When you say first time of the day, you mean after booting your system I guess. Another test you can do is shutting down your system and booting again. Probably it will take another 20 min and be faster afterwards.

        Waiting 20 minutes or even "only" 2 minutes is really long. You may want to think about ways to bridge those wating times. One possibility may be loading in a separate thread or possibly loading spread over different thread when on a multi core machine.

        Vote the answer(s) that helped you to solve your issue(s)

        1 Reply Last reply Reply Quote 0
        • M
          mcosta last edited by mcosta

          hi,

          if your DB runs on the same machine probably it uses cache to optimize some queries; so could be the reason of this behaviour

          Once your problem is solved don't forget to:

          • Mark the thread as SOLVED using the Topic Tool menu
          • Vote up the answer(s) that helped you to solve the issue

          You can embed images using (http://imgur.com/) or (http://postimage.org/)

          1 Reply Last reply Reply Quote 0
          • R
            reezeus last edited by

            Hi koahnig & mcosta,

            @koahnig-
            I have not tested to shut down and the run it again, I'll try it, but you are certainly right. 2 mins may sounds very long indeed, but there are billions of calculations, and basically I am happy to be able to run it in 2 mins (The first time I wrote the code for this purpose, it was in VBA and used to take 25/30 mins (everytime ;) ).

            @mcosta-
            Your idea seems very likely to be a good explanation, I have not think about it. Indeed the DB is a local one.
            Is there a way to load the cache before? (maybe opening and closing an ODBC connection prior to run my function?)

            Thanks for your help

            1 Reply Last reply Reply Quote 0
            • M
              mcosta last edited by

              @reezeus said:

              Is there a way to load the cache before?

              I don't know. But you should refer to the DB documentation

              Once your problem is solved don't forget to:

              • Mark the thread as SOLVED using the Topic Tool menu
              • Vote up the answer(s) that helped you to solve the issue

              You can embed images using (http://imgur.com/) or (http://postimage.org/)

              1 Reply Last reply Reply Quote 0
              • R
                reezeus last edited by

                Ok thanks, I'll look at it.
                Cheers

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post