Ascer Posted March 25, 2020 Posted March 25, 2020 Hello again, I looking for fast possible way to insert single line to EditBox GuiCtrlCreateEdit. BeginUpdate -> set data -> endUpdate cant be used! #include <GUIConstantsEx.au3> Example() Func Example() Local $msg, $diff, $time, $hEdit GUICreate("My GUI", 400, 250) $hEdit = GUICtrlCreateEdit("", 0, 0, 400, 150) GUISetState() $time = TimerInit() For $i = 1 To 100 GUICtrlSetData($hEdit, "GUICtrlSetData" & @CRLF, 1) Next $diff = Int(TimerDiff($time) * 100)/100 GUICtrlCreateLabel("GUICtrlSetData: " & $diff & "ms", 10, 170) $time = TimerInit() For $i = 1 To 100 GUICtrlSendMsg($hEdit, 0xC2, 0, "GUICtrlSendMsg $EM_REPLACESEL" & @CRLF) Next $diff = Int(TimerDiff($time) * 100)/100 GUICtrlCreateLabel("GUICtrlSendMsg: " & $diff & "ms", 10, 190) While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd EndFunc ;==>Example
Nine Posted March 25, 2020 Posted March 25, 2020 $time = TimerInit() For $i = 1 To 100 ControlSetText ($hGUI, "", $hEdit, "ControlSetText" & @CRLF) Next $diff = Int(TimerDiff($time)) GUICtrlCreateLabel("ControlSetText: " & $diff & "ms", 10, 210) 124ms “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy
jchd Posted March 26, 2020 Posted March 26, 2020 Begin/End can be used! Fair comparison: expandcollapse popup___Example() Func ___Example() Local $msg, $diff, $time, $hEdit GUICreate("My GUI", 400, 260) $hEdit = GUICtrlCreateEdit("", 0, 0, 400, 150) GUISetState() $time = TimerInit() _GUICtrlEdit_BeginUpdate($hEdit) For $i = 1 To 100 GUICtrlSetData($hEdit, "GUICtrlSetData" & @CRLF, 1) Next _GUICtrlEdit_EndUpdate($hEdit) $diff = TimerDiff($time) / 100 GUICtrlCreateLabel("Raw GUICtrlSetData: " & $diff & "ms", 10, 170) GUICtrlSetData($hEdit, "") ; clear content $time = TimerInit() _GUICtrlEdit_BeginUpdate($hEdit) For $i = 1 To 100 GUICtrlSetData($hEdit, "GUICtrlSetData" & @CRLF, 1) Next _GUICtrlEdit_EndUpdate($hEdit) $diff = TimerDiff($time) / 100 GUICtrlCreateLabel("GUICtrlSetData with Begin/End: " & $diff & "ms", 10, 190) GUICtrlSetData($hEdit, "") ; clear content $time = TimerInit() _GUICtrlEdit_BeginUpdate($hEdit) Local $s For $i = 1 To 100 $s &= "GUICtrlSetData" & @CRLF Next GUICtrlSetData($hEdit, $s) _GUICtrlEdit_EndUpdate($hEdit) $diff = TimerDiff($time) / 100 GUICtrlCreateLabel("Block GUICtrlSetData: " & $diff & "ms", 10, 210) GUICtrlSetData($hEdit, "") ; clear content $time = TimerInit() For $i = 1 To 100 GUICtrlSendMsg($hEdit, 0xC2, 0, "GUICtrlSendMsg $EM_REPLACESEL" & @CRLF) Next $diff = TimerDiff($time) / 100 GUICtrlCreateLabel("GUICtrlSendMsg: " & $diff & "ms", 10, 230) While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd EndFunc ;==>___Example This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)
Ascer Posted March 26, 2020 Author Posted March 26, 2020 @jchd You make an huuuge mistake here: $diff = TimerDiff($time) / 100 My goal is to make chat Console for TCP client so after adding new line script should fast as possible back to received message loop.
Nine Posted March 26, 2020 Posted March 26, 2020 (edited) Ok my previous was not exactly fair, but it is still the fastest : expandcollapse popup#include <GUIConstantsEx.au3> #include <GuiEdit.au3> Example() Func Example() Local $msg, $diff, $time Global $hGUI = GUICreate("My GUI", 400, 250) Global $hEdit = GUICtrlCreateEdit("", 0, 0, 400, 150) GUISetState() $time = TimerInit() For $i = 1 To 100 GUICtrlSetData($hEdit, "GUICtrlSetData" & @CRLF, 1) Next $diff = int(TimerDiff($time)) GUICtrlCreateLabel("GUICtrlSetData: " & $diff & "ms", 10, 170) $time = TimerInit() For $i = 1 To 100 GUICtrlSendMsg($hEdit, 0xC2, 0, "GUICtrlSendMsg $EM_REPLACESEL" & @CRLF) Next $diff = Int(TimerDiff($time)) GUICtrlCreateLabel("GUICtrlSendMsg: " & $diff & "ms", 10, 190) $time = TimerInit() For $i = 1 To 100 AddText ("ControlSetText" & @CRLF) Next $diff = Int(TimerDiff($time)) GUICtrlCreateLabel("ControlSetText: " & $diff & "ms", 10, 210) $time = TimerInit() For $i = 1 To 100 _GUICtrlEdit_AppendText ($hEdit, "AppendText" & @CRLF) Next $diff = Int(TimerDiff($time)) GUICtrlCreateLabel("AppendText: " & $diff & "ms", 10, 230) While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd EndFunc ;==>Example Func AddText ($sTxt) Local Static $sEditText $sEditText &= $sTxt ControlSetText ($hGUI, "", $hEdit, $sEditText) EndFunc So far... Edited March 26, 2020 by Nine “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy
Ascer Posted March 26, 2020 Author Posted March 26, 2020 Guys make tests on this example is more realistic in my case. Try to speed up it. Example() Func Example() Local $hGUI, $hEdit, $hButton, $hLabel, $time, $diff $hGUI = GUICreate("Test", 500, 500) $hEdit = GUICtrlCreateEdit("", 10, 10, 400, 400, 2099200) $hButton = GUICtrlCreateButton("Add", 10, 450, 80, 30) $hLabel = GUICtrlCreateLabel("", 10, 420, 100, 20) GUISetState() For $i = 1 To 100 GUICtrlSetData($hEdit, "Example add new line with some text bla bla bah" & @CRLF, 1) Next GUICtrlSendMsg($hEdit, 0xB1, 9999, 9999) While 1 Switch GUIGetMsg() Case -3 Exit Case $hButton $time = TimerInit() GUICtrlSetData($hEdit, "Example add new line with some text bla bla bah" & @CRLF, 1) $diff = TimerDiff($time) GUICtrlSetData($hLabel, "Time: " & Int($diff * 100)/ 100 & "ms") EndSwitch WEnd EndFunc
Deye Posted March 26, 2020 Posted March 26, 2020 (edited) The bigger the buffer that holds data the longer it will take = make $hEdit smaller in size and notice a speed up Edited March 26, 2020 by Deye
Ascer Posted March 26, 2020 Author Posted March 26, 2020 You right but this not solve problem the editbox can't be small it should be almost full screen mode
jchd Posted March 26, 2020 Posted March 26, 2020 (edited) 3 hours ago, Ascer said: You make an huuuge mistake here: Which "huge mistake" please? That's the time in ms used for inserting a line and displaying it. Your * 100 / 100 is a no-op. And I'd say something like 2.2 ms (on my old PC) is perfectly negligible. Edited March 26, 2020 by jchd This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)
Ascer Posted March 26, 2020 Author Posted March 26, 2020 If TimerDiff return value in ms then you use / 100 and value is for single insert instead of all 100 lines.
argumentum Posted March 26, 2020 Posted March 26, 2020 3 hours ago, Ascer said: after adding new line script should fast as possible back to received message loop hmmm, so, single thread in a loop waiting for ... something. Delegate Use an IPC to populate the edit control, or, leave it for later when the loop idle for say, 100 ms. Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now