Results 1 to 9 of 9

Thread: [RESOLVED] Algorithm speed after compiled

  1. #1

    Thread Starter
    Fanatic Member Episcopal's Avatar
    Join Date
    Mar 2019
    Location
    Brazil
    Posts
    547

    Resolved [RESOLVED] Algorithm speed after compiled

    Hello everybody

    I know that when we compile the program it runs faster than in development mode in the IDE.
    The problem here is that I put a TIMER to measure the speed, and an MSGBOX to display the results.
    In design mode and after compilation, the speed is the same.



    Regardless of the code, it shouldn't be faster after compiling.

  2. #2

    Thread Starter
    Fanatic Member Episcopal's Avatar
    Join Date
    Mar 2019
    Location
    Brazil
    Posts
    547

    Re: Algorithm speed after compiled

    Code:
    Dim vTimer As Single
        	vTimer = Timer
    
    	Do
            newStartPos = SendMessageLong(m_Settings.EditHwnd, EM_FORMATRANGE, False, _
                    VarPtr(m_Settings.FormatRange))
          
            If newStartPos >= TextLength Then
                Exit Do
            End If
            m_Settings.FormatRange.mCharRange.firstChar = newStartPos
            iPageCtn = iPageCtn + 1
       	Loop
    
    	MsgBox Timer - vTimer

  3. #3
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,906

    Re: Algorithm speed after compiled

    There is nothing where speed can be gained. All time is in the external calls

  4. #4

    Thread Starter
    Fanatic Member Episcopal's Avatar
    Join Date
    Mar 2019
    Location
    Brazil
    Posts
    547

    Re: Algorithm speed after compiled

    I did a test with Microsoft Office Word 2021 and it also takes a long time to count the pages.
    I put a document with 15,000 pages in the quoted Word.... and every letter typed it crashes for a while.

  5. #5
    Frenzied Member
    Join Date
    Dec 2012
    Posts
    1,477

    Re: Algorithm speed after compiled

    You need to force higher precision in the calculation, and you have to realize that there is a minimum because of the Tick Counter.
    Code:
    Dim Start as Double
    Start = Timer
    ..
    ..
    ..
    Debug.Print "Time: " & (CDbl(Timer) - Start) * 1000 & " ms"
    For more information, see:
    https://www.vbforums.com/showthread....recision-Timer

    J.A. Coutts

  6. #6

    Thread Starter
    Fanatic Member Episcopal's Avatar
    Join Date
    Mar 2019
    Location
    Brazil
    Posts
    547

    Re: Algorithm speed after compiled

    Thanks JA Coutts for the link, I'll definitely check it out...

    But the real problem is the algorithm I posted, because if you insert a document with more than 15000 it crashes for a while, even in Word 2021.

    But I will implement STimerEx for better measurement.

  7. #7

    Thread Starter
    Fanatic Member Episcopal's Avatar
    Join Date
    Mar 2019
    Location
    Brazil
    Posts
    547

    Re: Algorithm speed after compiled

    Office Word 2021 is still slower than my component.
    Last edited by Episcopal; Sep 22nd, 2022 at 07:27 PM.

  8. #8
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,163

    Re: Algorithm speed after compiled

    The “algorithm” you are using is trivial (a single loop) and this cannot be further optimized. The only option would be to stop using EM_FORMATRANGE which does not sound feasable. It is this message impl that a million more things are done than in your “algorithm” and you cannot optimize EM_ FORMATRANGE external implementation.

  9. #9

    Thread Starter
    Fanatic Member Episcopal's Avatar
    Join Date
    Mar 2019
    Location
    Brazil
    Posts
    547

    Re: Algorithm speed after compiled

    Arnoutdv and wqweto, you are right. The API call cannot be changed because "it" is outside of my system, so I didn't see any difference in time between design and compiled mode.

    Come to think of it, there's nothing you can do.


    Quote Originally Posted by wqweto View Post
    The only option would be to stop using EM_FORMATRANGE which does not sound feasable.
    qweto there is a replacement for EM_FORMATRANGE???

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width