Tankbuster

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

14 posts in this topic

#1 ·  Posted (edited)

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

Share this post


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.

 

1 person likes this

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


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.

 

 

Share this post


Link to post
Share on other sites

:)


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Share this post


Link to post
Share on other sites

Just tested. Makes no difference :(

 


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


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.

Share this post


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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


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.

Share this post


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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


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.

Share this post


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.

Share this post


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

  • Similar Content

    • FrancescoDiMuro
      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
       
    • AndreyS
      By AndreyS
      Please tell me, who knows how to apply and cancel styles in RTF?
      The following code does not work:
      #include <GuiRichEdit.au3> #include <WindowsConstants.au3> $hGUI = GUICreate("RichEdit Style", 500, 500, -1, -1) $hRichEdit = _GUICtrlRichEdit_Create($hGui, "Test", 20,40,460,400) GUISetState(@SW_SHOW, $hGUI) Sleep(3000) GUICtrlSetStyle($hRichEdit, $ES_RIGHT) Sleep(3000) GUICtrlSetStyle($hRichEdit, -1) Sleep(3000) Thanks!
    • AndreyS
      By AndreyS
      Tell me, please, why in the application of different styles($SS_BLACKFRAME, $SS_BLACKRECT, etc.) of frames stops working function Msg().
      And why in the application of certain frame styles($SS_BLACKFRAME) do not even picture displayed?
      #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> Opt("GUIOnEventMode", 1) Example() Func Example() GUICreate("My GUI picture", 350, 300, -1, -1) ; will create a dialog box that when displayed is centered GUISetOnEvent($GUI_EVENT_CLOSE,"Quit") $idPic = GUICtrlCreatePic("D:\Program Files\AutoIt3\Examples\GUI\mslogo.jpg", 50, 50, 200, 50, $SS_SUNKEN) GUICtrlSetOnEvent(-1,"Msg") GUISetState(@SW_SHOW) ; Loop until the user exits. While 1 WEnd EndFunc ;==>Example Func Msg() MsgBox(0,0,0) EndFunc Func Quit() Exit EndFunc  
    • TheAutomator
      By TheAutomator
      Hi, i'm not a very educated guy when it comes to dll calls..
      can someone help me do this:
      DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", false) for only one control?
    • MattHiggs
      By MattHiggs
      I have the following code which is meant to change the "extended style" of all the GUIs in the project, but it doesn't want to take.  I thought I followed the help file, when the tray icon is checked, leave the standard styles as their defaults and add $WS_EX_TOPMOST to the extended styles, and when unchecked, set the styles back to what the GUI was originally created with.  Please help:
      #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Res_SaveSource=y #AutoIt3Wrapper_Res_requestedExecutionLevel=requireAdministrator #AutoIt3Wrapper_Add_Constants=n #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.15.0 (Beta) Author: myName Script Function: Template AutoIt script. #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here #include <GUIConstantsEx.au3> ; *** End added by AutoIt3Wrapper *** ; *** Start added by AutoIt3Wrapper *** #include <FontConstants.au3> ; *** End added by AutoIt3Wrapper *** ; *** Start added by AutoIt3Wrapper *** #include <ListViewConstants.au3> #include <WindowsConstants.au3> ; *** End added by AutoIt3Wrapper *** ; *** Start added by AutoIt3Wrapper *** #include <GUIConstants.au3> ; *** End added by AutoIt3Wrapper *** ; *** Start added by AutoIt3Wrapper *** #include <AutoItConstants.au3> #include <ListBoxConstants.au3> #include <MsgBoxConstants.au3> #include <Array.au3> #include <GuiListView.au3> #include <FileConstants.au3> #include <StaticConstants.au3> #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <Constants.au3> #include <Misc.au3> #include <GuiButton.au3> #include <MsgBoxConstants.au3> #include <GuiListBox.au3> #include <GuiListView.au3> #include <Crypt.au3> Const $path = @AppDataDir & "\filler" Opt ( "TrayMenuMode", 1 ) $nonote = False $TrayMenu = TrayCreateMenu ( "Settings" ) $settings1 = TrayCreateItem ( "Turn off notifications", $TrayMenu ) TrayItemSetState ( -1, Int ( IniRead ( $path & "\infostore.ini", "Tray Settings", "No Notifications", "68" ) ) ) $settings2 = TrayCreateItem ( "Keep Window on top", $TrayMenu ) TrayItemSetState ( -1, Int ( IniRead ( $path & "\infostore.ini", "Tray Settings", "On top", "68" ) ) ) $Form1_1 = GUICreate("Form filler", 701, 659, 317, 125, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_SIZEBOX, $WS_THICKFRAME, $WS_TABSTOP)) If TrayItemGetState ( $settings2 ) = 65 Then GUISetStyle ( -1, $WS_EX_TOPMOST ) EndIf GUISetState(@SW_SHOW, $Form1_1) While 1 $tmsg = TrayGetMsg () $nMsg = GUIGetMsg() Switch $tmsg Case $TrayMenu Case $settings1 #Region --- CodeWizard generated code Start --- ;MsgBox features: Title=Yes, Text=Yes, Buttons=OK, Icon=None MsgBox($MB_OK,"State",TrayItemGetState ($settings1)) #EndRegion --- CodeWizard generated code End --- If TrayItemGetState ( $settings1 ) = 65 Then IniWrite ( $path & "\infostore.ini", "Tray Settings", "No Notifications", "65" ) ElseIf TrayItemGetState ( $settings1 ) = 68 Then IniWrite ( $path & "\infostore.ini", "Tray Settings", "No Notifications", "68" ) Else EndIf Case $settings2 If TrayItemGetState ( $settings2 ) = 65 Then IniWrite ( $path & "\infostore.ini", "Tray Settings", "On top", "65" ) GUISetStyle ( -1, $WS_EX_TOPMOST, $Form1_1 ) ElseIf TrayItemGetState ( $settings2 ) = 68 Then IniWrite ( $path & "\infostore.ini", "Tray Settings", "On top", "68" ) GUISetStyle ( BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_SIZEBOX, $WS_THICKFRAME, $WS_TABSTOP), 0, $Form1_1 ) Else EndIf EndSwitch Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd While this is a snippet of the code, it is the portion which illustrates my issue and can be compiled, so have at it.