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 post
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 2022-02-19 - Version 1.6.1.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 (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

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

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to post
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 post
Share on other sites

:)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

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

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to post
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 post
Share on other sites

Just tested. Makes no difference :(

 

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

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

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to post
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 post
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 2022-02-19 - Version 1.6.1.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 (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

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

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to post
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 post
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 2022-02-19 - Version 1.6.1.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 (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

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

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to post
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 post
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 2022-02-19 - Version 1.6.1.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 (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

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

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to post
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 post
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 post
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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By cdeb
      How can you select the specific style of a font with multiple * .otf files?
      The font in question has several files:
       
      Thin Thin Italic Extra-Light Extra-Light Italic Light Light Italic Regular Regular Italic Medium Medium Italic Semi-Bold Semi-Bold Italic Bold Bold Italic Extra-Bold Extra-Bold Italic Black Black Italic But after doing several tests I can recall the font like this, without being able to specify the precise style:
      Local $hFamily = _GDIPlus_FontFamilyCreate("Poppins") ; Local $hFont = _GDIPlus_FontCreate($hFamily, 95, 1+2, 3) ; Example I cannot therefore select "Poppins Black Italic"
      but only "Poppins" 
      Thank you

    • By Reher
      Hi
      so i ran into a Problem i didn't expect to get stuck on.
      It sounds simple (and probably is) but i can't seem to get it to work
      So i created a Combobox and filled it with some things from an array which worked fine.
      $combobox = GUICtrlCreateCombo($list[0], 160, 200, 265, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) GuiCtrlSetData($list, "|" & _ArrayToString($list,Default,1),$list[2]) GUICtrlSetFont(-1, 9, 400, 0, "Arial") Now i want to change the style of the combobox from $CBS_DROPDOWN to $CBS_DROPDOWNLIST via a checkbox.
      $Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 160, 96, 105, 25) Case $Checkbox1 If GUICtrlRead($Checkbox1) = $GUI_CHECKED Then Call ("Read_only") Else Call ("Edit") Endif Func Read_only() GUICtrlSetStyle ($Combobox1,something to change it to $CBS_DROPDOWNLIST) EndFunc Func Edit() GUICtrlSetStyle ($Combobox1,something to change it to $CBS_DROPDOW) EndFunc I tried using $CBS_DROPDOWN and $CBS_DROPDOWNLIST but it simply does nothing.
      I also tried $ES_READONLY which kinda worked, it changed the combobox so i couldn't change the input via dropdown anymore but i could still type in it via keyboard (which i dont want).
      It's essential that its Editable but once the checkbox is checked the combobox becomes readonly so you can't type in it anymore but you can still choose between the items in the list. (It does not have to save your current input if you write something in it and then check the Checkbox it would be best if it would simpy jump back to the first item in the list)
      Im sure this is a simple thing but after long google search im tired of my stupidity can someone give me a push in the right direction?
    • By nacerbaaziz
      Hello
      Dear Sirs, I have a question please
      About UPDown ctrl
      Where I want to adjust its format
      For example, I want to create a window to set the clock like the window in the system
      Can this be done?
      here's the example
      ______

      #include <WindowsConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <UpDownConstants.au3> goto() func Goto() local $wGoto = GUICreate("go to spissific position", 250, 180, @DesktopWidth / 2 - 192, @DesktopHeight / 2 - 235, -1) GUICtrlCreateLabel("please write a corect position to go to it", 50, 10, 220, 20) GUICtrlCreateLabel("hours", 0, 80, 100, 30) local $Inp1 = GUICtrlCreateInput("00", 0, 90, 100, 20, $ES_NUMBER + $WS_TABSTOP)     GUICtrlCreateUpdown($Inp1, $UDS_ARROWKEYS) GUICtrlSetLimit(-1, 23, 0) GUICtrlCreateLabel("minuts", 110, 80, 100, 30) local $Inp2 = GUICtrlCreateInput("00", 110, 90, 100, 20, $ES_NUMBER + $WS_TABSTOP)     GUICtrlCreateUpdown($Inp2, $UDS_ARROWKEYS) GUICtrlSetLimit(-1, 60, 0) GUICtrlCreateLabel("seconds", 220, 80, 100, 30) local $Inp3 = GUICtrlCreateInput("00", 220, 90, 100, 20, $ES_NUMBER + $WS_TABSTOP)     GUICtrlCreateUpdown($Inp3, $UDS_ARROWKEYS) GUICtrlSetLimit(-1, 60, 0) local $Ok = GUICtrlCreateButton("&ok", 0, 150, 50, 30, 0x01) local $cancel = GUICtrlCreateButton("&cancel", 200, 150, 50, 30) GUISetState(@sw_show, $WgoTo) while 1 switch GUIGetMSG() case $GUI_Event_Close, $cancel exit case $OK local $read1 = GUICtrlRead($inp1) if $read1 >= 1 then $Read1 = ($Read1*60)*60 local $read2 = GUICtrlRead($inp2) if $read2 >= 1 then $Read2 = $Read2*60 local $read3 = GUICtrlRead($inp3) GUIDelete($WgoTo) Return $read1+$read2+$read3 exit endSwitch Wend EndFunc
      ________
      What I need is to be the contents of the inputs as follows when i change the value of the UPDown CTRL
      00
      01
      02
      03
      ...
       
    • By nacerbaaziz
      Hello, dears.
      First I apologise to you for the stupid question I'm going to ask.
      is the default style for Windows created using AutoIt   a dialog box style?
      I decided to ask this question
      Because I am using a screen reader
      If i open any program that is designed using autoit, the screen reader read for example,  
      test dialog
      but If i open any other program, for example goldwave, it read goldwav only without a word dialog
      Is there a solution to this
      The code i used to create the window is:
      $hGUI = GUICreate(str("title"), 500, 420, -1, -1, BitOr($WS_MAXIMIZEBOX, $WS_MINIMIZEBOX, $WS_SIZEBOX, $WS_SYSMENU, $WS_CAPTION), BitOr($WS_EX_ACCEPTFILES,$WS_EX_LAYERED,$WS_EX_CLIENTEDGE,$WS_EX_STATICEDGE))
      I hope to find a solution to this problem
      please Accept my greetings, and thank you very much.
    • By FrancescoDiMuro
      Good morning
      I was looking around the forum if there were some customizable solutions about creating a PDF from "0" to something like a report...
      What I'd like to do is something with a header ( 2 logos and a title ), with a table which contains data read from a file
      At the moment, I was working with HTML, since I know it and it's very simple to do a table with some data inside...
      But know, I'm a bit stuck about the exporting the HTML page to PDF... And, here too, if someone knows how to do it, please, I'm here listening
      Thanks guys
       
×
×
  • Create New...