Announcement

Collapse

New Sub-Forum

In an effort to help make sure there are appropriate categories for topics of discussion that are happening, there is now a sub-forum for databases and database programming under Special Interest groups. Please direct questions, etc., about this topic to that sub-forum moving forward. Thank you.
See more
See less

Not the usual speed issue

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • #21
    When I start Solitaire and give it the focus, your app speed jumps up to 200 fps (from 64fps).
    That makes sense. The foreground window (Solitaire in this case) is assigned a higher priority or gets more time slice attention than do "other" programs and so the time-consuming screen updates are done less often.

    Also I will guess Windows itself uses "regions" to update only the portions of screen which are visible, so if Solitaire is obscuring part of this application (or this application is minimized) then Windows finds less to do than when it's wholly visible.

    Don't know how GRAPHICS REDRAW is implemented... but a very common technique for forcing a redraw of a Window is..
    Code:
        InvalidateRect  hWnd, BYVAL %NULL, 0   
        UpdateWindow hWnd
    While param #2 to InvalidateRect specifies a RECT structure - in theory the rectangle representing the portion of the client area you just changed - using NULL here invalidates the ENTIRE client area and so when repainting the ENTIRE client area is repainted because it's ALL invalidated.

    MCM
    Michael Mattias
    Tal Systems Inc. (retired)
    Racine WI USA
    [email protected]
    http://www.talsystems.com

    Comment


    • #22
      Originally posted by Michael Mattias View Post
      While param #2 to InvalidateRect specifies a RECT structure - in theory the rectangle representing the portion of the client area you just changed - using NULL here invalidates the ENTIRE client area and so when repainting the ENTIRE client area is repainted because it's ALL invalidated.
      I think you need to use InvalidateRgn to get that result - see various postings on the topic of "dirty rects".

      Comment


      • #23
        time-consuming screen updates are done less often.
        This is not the case with this particular program, as the program remains visible and the incrementing is noticeably increased. That was how I became aware of it.

        Yet, there should be an element of truth to what you say, methinks. Is it possible that since running the app in the background while Solitaire has focus means, since each have their own thread of execution, that the background app is relegated to the second core?

        I just finished another comparison run with David's Maximize Timer Resolution, and it did not have the effect that the first run had. With his program running, mine took 71.93703, and without his running it took less than a minute longer. I may have messed up somewhere so I want to try that again with the larger numbers.

        Edit: I just remembered that this program sort of benefits from the higher star count, a little more efficient with higher 'star' count but it shouldn't make that much difference.

        But an image of the just finished run:
        Attached Files
        Last edited by Rodney Hicks; 26 Aug 2014, 06:26 PM. Reason: add info
        Rod
        I want not 'not', not Knot, not Knott, not Nott, not knot, not naught, not nought, but aught.

        Comment


        • #24
          BTW, Rod, in the same thread as MTR, here, there is another little application called TimerRes in post #4. Executing that gives the current resolution.

          I have just included Solitaire and when running TimerRes tells me that the current resolution is 1ms. The previous resolution was 15.6ms and it returned to that on closing Solitaire.

          Comment


          • #25
            BTW, Rod, in the same thread as MTR, here, there is another little application called TimerRes in post #4.
            I saw that, was thinking about giving it a go. And I shasll.

            I tried a second long run and got much the same result as the first time. Could be some scheduled app affecting the outcome, perhaps. I'll have to try shutting everything down for a day or so.
            Rod
            I want not 'not', not Knot, not Knott, not Nott, not knot, not naught, not nought, but aught.

            Comment


            • #26
              Left Run 1 and 2 were with nothing else active on the screen.
              Right Run 1 and 2 were with Solitaire active covering your app by 75%.
              Click image for larger version  Name:	New Bitmap Image.jpg Views:	0 Size:	60.0 KB ID:	796114

              The next 2 were measured when Solitaire was in focus but not covering your app.

              Click image for larger version  Name:	New Bitmap Image.jpg Views:	0 Size:	28.5 KB ID:	796115
              My system is a 10 year old Core Duo Laptop.

              Comment


              • #27
                Egads, that's from 7 years ago or so, back when I was young and ignorant.

                I just ran the code from post #1 on my high faluting 8 core machine with Win 10, kept it in focus for the run and apparently M$ figured out how to slow it down without my help for it only ran at 28.9 frames per second.

                Not that I wanted it slower, of course.
                Rod
                I want not 'not', not Knot, not Knott, not Nott, not knot, not naught, not nought, but aught.

                Comment


                • #28
                  Originally posted by Rodney Hicks View Post
                  Egads, that's from 7 years ago or so, back when I was young and ignorant.
                  Yep, it seems that Jim has a lot of time on his hands these days, he's resurrected a lot of dead 5-10 year old threads recently

                  Comment


                  • #29
                    And I'm loving it. Nice to see what happens in a new era with a fresh/old set of eyes.
                    Yes, 0-20 years looking for useful nuggets. That's what happens when your methods have changed and you need more info.

                    Rodney,
                    Interesting, I would not have expected it; that is, to see a Core Duo laptop outperform a newer 8 core machine on one task.

                    The underlying question that was not answered so far was how can you programmatically get more clock pulses assigned to your app?

                    One method I have used successfully for years is to produce a short MP3 file of silence and save it in the app folder. The app plays that MP3 in a loop continuously. Doing that puts the app in a higher priority state. Why do I do that? So my USB interface which my app uses runs at the highest speed possible. ~10-30 times faster.

                    If it works on the USB interface it should also help the app perform other tasks.

                    Alas, I did not modify your app to do that.

                    Thanks for the opportunity to play Solitaire.
                    Yours truly, AKA "NecroPoster"
                    Last edited by Jim Fritts; 27 Jun 2020, 10:53 AM.

                    Comment


                    • #30
                      Yes, Stuart, I had noticed that! There's been a lot of good stuff through the years.

                      The underlying question that was not answered so far was how can you programmatically get more clock pulses assigned to your app?
                      Jim, Paul Dixon's suggestion of TimeBeginPeriod (post #8) seemed to do the trick.
                      Rod
                      I want not 'not', not Knot, not Knott, not Nott, not knot, not naught, not nought, but aught.

                      Comment


                      • #31
                        Rodney,
                        Oh really? I didn't notice any changes to post #1 based on Paul's assumption. The numbers that were reported do not match any tests I made. In fact your recent test demonstrated the problem was with the OS not the app. At any rate that was my takeaway from testing. I'm just saying...

                        Comment


                        • #32
                          Post #11 shows the results of testing the TimeBeginPeriod with different values but apparently I didn't post the code, which if I recall correctly, was just adding TimeBeginPeriod()/TimeEndPeriod() pair in the appropriate places.
                          I haven't tested the same under Win 10...yet. I'm trying not lose my focus on my current 'World's Most Fantastic Program #675888388'.
                          And yes, OS seems to have some added implication.
                          Rod
                          I want not 'not', not Knot, not Knott, not Nott, not knot, not naught, not nought, but aught.

                          Comment


                          • #33
                            Originally posted by Jim Fritts View Post
                            recent test demonstrated the problem was with the OS not the app. At any rate that was my takeaway from testing. I'm just saying...
                            It's not so much a "problem" as a "speed boost in certain situations".
                            TimeBeginPeriod has an effect at OS level.
                            "This function affects a global Windows setting. Windows uses the lowest value (that is, highest resolution) requested by any process."

                            Apparently Solitaire sets it at a high resolution which is why this application runs faster when Solitaire is loaded. You can get the same effect by changing the resolution directly in the application.
                            Last edited by Stuart McLachlan; 27 Jun 2020, 02:31 PM.

                            Comment


                            • #34
                              Stuart, yes. And Win 10 has a different Solitaire game and a lot more 'services' running than when I think it was Vista was running at the time of first posting.
                              Rod
                              I want not 'not', not Knot, not Knott, not Nott, not knot, not naught, not nought, but aught.

                              Comment


                              • #35
                                As you can see in my tests. The Solitaire app reduced the frame rate not speed it up which is what should have been expected at the time in Vista. Yes, the OS had some problems but you found a method to accelerate it just like I did (in my case it was playing an MP3 file in the background). You could have also used SetPriorityClass at ABOVE_NORMAL_PRIORITY_CLASS or better yet at HIGH_PRIORITY_CLASS.

                                Comment


                                • #36
                                  Yes, priorities, priorities!!
                                  Rod
                                  I want not 'not', not Knot, not Knott, not Nott, not knot, not naught, not nought, but aught.

                                  Comment


                                  • #37
                                    Nope. Sorry.
                                    I tried HIGH and REALTIME. It made no difference.

                                    Comment


                                    • #38
                                      Ya forced me into it. Tried TimeSetPriority/TimeEndPriority and got less than a .2 frame/second difference so the OS is now the mitigating or something like that factor.
                                      Rod
                                      I want not 'not', not Knot, not Knott, not Nott, not knot, not naught, not nought, but aught.

                                      Comment


                                      • #39
                                        Originally posted by Jim
                                        (in my case it was playing an MP3 file in the background)
                                        When you do that the timer interval reduces to 1ms from 15.625ms, or whatever.

                                        Comment


                                        • #40
                                          David,
                                          You betcha.

                                          And I use mciSendStringA to play the MP3.

                                          Comment

                                          Working...
                                          X