-
Sep 22nd, 2022, 12:40 PM
#1
Thread Starter
Fanatic Member
[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.
-
Sep 22nd, 2022, 12:53 PM
#2
Thread Starter
Fanatic Member
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
-
Sep 22nd, 2022, 04:04 PM
#3
Re: Algorithm speed after compiled
There is nothing where speed can be gained. All time is in the external calls
-
Sep 22nd, 2022, 05:16 PM
#4
Thread Starter
Fanatic Member
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.
-
Sep 22nd, 2022, 05:28 PM
#5
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
-
Sep 22nd, 2022, 06:12 PM
#6
Thread Starter
Fanatic Member
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.
-
Sep 22nd, 2022, 06:40 PM
#7
Thread Starter
Fanatic Member
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.
-
Sep 23rd, 2022, 02:34 AM
#8
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.
-
Sep 23rd, 2022, 07:49 AM
#9
Thread Starter
Fanatic Member
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.
Originally Posted by wqweto
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|