Jump to content

[SOLVED] Edit Control slow update / any chance to speed up


Recommended Posts

Hello,

A small tool from me opens certain text files and displays the content in some sort of "preview", by chance a user selected a file that is "large" ~ 10 MB. (of course my test files are small enough :-) )

But this takes very long (~ 4 secs on that pc), first I thought it is reading the file but I stripped it down to the edit control update.

 

I extracted the issue to a sample au3 attached and a sample large file.  The log lines are from the dummy1.au3.

(11:19:40.352) - -->Line0017):    openfile
(11:19:40.461) - -->Line0021):    closefile
(11:19:40.461) - -->Line0022):    update ctrlfile start
(11:19:45.581) - -->Line0024):    update ctrlfile done

I see that reading the file is fast enough( 109ms) , but the edit control update takes long (5120 ms).

 

Question: Based on the dummy1, is there a chance to speed up? I'm open to accept also other advices, the purpose of the edit is just to display the file and allow scrolling.

I thought about reading only a certain amount of lines and if the user scrolls read the rest.....or so.

Or is it just like this by design. Or what is more likely, what is wrong on my code?

 

Of course my real app displays now in the mean time something like "Loading...." but that does not solve it.

And yes, I used FS. Found something similar, but the thread was drifting apart from the issue without solving it...

 

dummy1.au3

largetextfile.txt

Edited by Tankbuster
Link to comment
Share on other sites

Takes 6 seconds here to process your dummy file.
When I remove $ES_AUTOVSCROLL + $WS_VSCROLL it dropes to 1.8 seconds.

 

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Too easy :-) , can't accept it .....

(I tried it my self without the flags before posting, but it does not improve that time, so I thought it must be something else)

 

Performed steps:

  •  I tried it your way, worked of course this time.
  • named me a jerk.

Thank you.

 

 

Link to comment
Share on other sites

:)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

If you add these lines, you can probably reduce update time to a few hundred milliseconds:

#include <GuiEdit.au3>

Local $hEdit = GUICtrlGetHandle($idMyedit)
_GUICtrlEdit_BeginUpdate($hEdit)
GUICtrlSetData($idMyedit,$fileContent)
_GUICtrlEdit_EndUpdate($hEdit)

 

Link to comment
Share on other sites

Just tested. Makes no difference :(

 

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

You still need to remove $ES_AUTOVSCROLL + $WS_VSCROLL:

(15:07:56.734) - -->Line0018):  openfile
(15:07:57.000) - -->Line0022):  closefile
(15:07:57.000) - -->Line0023):  update ctrlfile start
(15:07:57.187) - -->Line0028):  update ctrlfile done

Code:

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <FileConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>
#include <Debug.au3>
#include <GuiEdit.au3>


_DebugSetup("DummyApp",false,2)
Example()

Func Example()
    GUICreate("My GUI edit") ; will create a dialog box that when displayed is centered
  GUISetState(@SW_SHOW)
    Local $idMyedit = GUICtrlCreateEdit("", 10, 10, 300, 350)
  _MyDebug("openfile")
  local $hdFile=fileopen("largetextfile.txt",$FO_READ )
  local $fileContent=FileRead($hdFile)
  fileclose($hdFile)
  _MyDebug("closefile")
  _MyDebug("update ctrlfile start")
  Local $hEdit = GUICtrlGetHandle($idMyedit)
  _GUICtrlEdit_BeginUpdate($hEdit)
  GUICtrlSetData($idMyedit,$fileContent)
  _GUICtrlEdit_EndUpdate($hEdit)
  _MyDebug("update ctrlfile done")

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

        EndSwitch
    WEnd
    GUIDelete()
EndFunc   ;==>Example


  func _MyDebug($debugtext,$debugline = @ScriptLineNumber)
    _DebugOut ("("&@HOUR&":"&@MIN&":"&@SEC&"."&@MSEC&") - -->Line" & StringFormat("%04d", $debugline) & "):" & @TAB & $debugtext)
  EndFunc

 

Edited by LarsJ
Code
Link to comment
Share on other sites

Makes no difference here. With and without styles it takes 1.8 seconds.

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <FileConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>
#include <Debug.au3>
#include <GuiEdit.au3>

_DebugSetup("DummyApp", False, 2)
Example()

Func Example()
    GUICreate("My GUI edit") ; will create a dialog box that when displayed is centered
    GUISetState(@SW_SHOW)
    Local $idMyedit = GUICtrlCreateEdit("", 10, 10, 300, 350) ; , $ES_AUTOVSCROLL + $WS_VSCROLL)
    _MyDebug("openfile")
    Local $hdFile = FileOpen("largetextfile.txt", $FO_READ)
    Local $fileContent = FileRead($hdFile)
    FileClose($hdFile)
    _MyDebug("closefile")
    _MyDebug("update ctrlfile start")

    Local $hEdit = GUICtrlGetHandle($idMyedit)
    _GUICtrlEdit_BeginUpdate($hEdit)
    $iTimer = TimerInit()
    GUICtrlSetData($idMyedit, $fileContent)
    ConsoleWrite(TimerDiff($iTimer) & @CRLF)
    _GUICtrlEdit_EndUpdate($hEdit)

    _MyDebug("update ctrlfile done")

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

        EndSwitch
    WEnd
    GUIDelete()
EndFunc   ;==>Example


Func _MyDebug($debugtext, $debugline = @ScriptLineNumber)
    _DebugOut("(" & @HOUR & ":" & @MIN & ":" & @SEC & "." & @MSEC & ") - -->Line" & StringFormat("%04d", $debugline) & "):" & @TAB & $debugtext)
EndFunc   ;==>_MyDebug

 

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

When I run your code in the post above I get these results:

(15:21:18.718) - -->Line0018):  openfile
(15:21:18.968) - -->Line0022):  closefile
(15:21:18.968) - -->Line0023):  update ctrlfile start
198.737828411153
(15:21:19.171) - -->Line0030):  update ctrlfile done

Funny.

Link to comment
Share on other sites

Do you read the same file with the same size in your script?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

I have tested on my Windows 7 laptop. Under both 32 and 64 bit I get the same results as you. The fast results are from my old XP (32 bit). Funny. It tends to be reversed.

Link to comment
Share on other sites

Strange indeed. But as XP has reached EOL we shouldn't bother too much :)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

It seems as if the commands _GUICtrlEdit_BeginUpdate/_GUICtrlEdit_EndUpdate doesn't work on Windows 7. But they work on XP.

Link to comment
Share on other sites

I have done a few more tests. Neither on XP nor Win 7 the commands _GUICtrlEdit_BeginUpdate/_GUICtrlEdit_EndUpdate seems to improve the update time. The commands seems to have very little effect on an Edit control. With and without the commands the update time on XP is about 10 times faster than it is on Win 7. I think that a bug in these commands on Win 7 can be excluded. But I still have no idea why the update is so much faster on XP. Or how to achieve the same speed on Win 7.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...