youtuber Posted May 17, 2017 Share Posted May 17, 2017 When many words are added It works very slowly Is there a solution for this? It also uses a lot of CPU! Spoiler expandcollapse popup#include <Array.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Dim $aEditRead $Form1 = GUICreate("Form1", 581, 352, 192, 125) $Edit1 = GUICtrlCreateEdit("", 24, 32, 145, 225) GUICtrlSetData(-1, "Autoit" & @CRLF & "autoit" & @CRLF & "autoitscript" & @CRLF & "autoitscript" & @CRLF & "123" & @CRLF & "123" & @CRLF & "Autoitscript" & @CRLF & "autoitscript.com" & @CRLF & "autoitscript.coM" & @CRLF & "Autoitscript" & @CRLF & "123a" & @CRLF & "123A" & @CRLF & "AutoitscripT") $Edit2 = GUICtrlCreateEdit("" & @CRLF, 184, 32, 145, 225, BitOR($ES_MULTILINE, $ES_AUTOVSCROLL, $WS_VSCROLL)) GUICtrlSetData(-1, "") $Button1 = GUICtrlCreateButton("Delete similar", 24, 296, 70, 33) $Label2 = GUICtrlCreateLabel("", 208, 272, 46, 17) $Button2 = GUICtrlCreateButton("Copy", 200, 296, 75, 33) $Edit3 = GUICtrlCreateEdit("" & @CRLF, 344, 32, 185, 225, BitOR($ES_MULTILINE, $ES_AUTOVSCROLL, $WS_VSCROLL)) $Label1 = GUICtrlCreateLabel("Similar ones", 368, 272, 97, 24) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 _deletesimilar() EndSwitch WEnd Func _deletesimilar() $aEditRead = StringSplit(StringStripCR(GUICtrlRead($Edit1)), @LF,2) $aUniques=_ArrayUnique($aEditRead, 0, 0, 1) $aUniques2=_ArrayUnique($aEditRead) For $i = 1 To UBound($aUniques) - 1 $aPos = _ArrayFindAll($aEditRead, $aUniques[$i], 0, 0, 1) If UBound($aPos) > 1 Then GUICtrlSetData($Edit2, $aUniques[$i] & @CRLF, 1) Next GUICtrlSetData($Label2, "Deleted") Dim $aSimilar[UBound($aEditRead)] $c = 0 For $i = 1 To UBound($aUniques2) - 1 $aPos = _ArrayFindAll($aEditRead, $aUniques2[$i]) If UBound($aPos) > 0 Then For $j = 0 To UBound($aPos) - 1 $aSimilar[$c] = $aEditRead[$aPos[$j]] $c += 1 Next EndIf Next ReDim $aSimilar[$c] $aUniques3=_ArrayUnique($aSimilar, 0, 0, 1) _ArraySort($aUniques3) For $i = 1 to UBound($aUniques3) - 1 GUICtrlSetData($Edit3, $aUniques3[$i] & @CRLF, 1) Next EndFunc Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted May 17, 2017 Moderators Share Posted May 17, 2017 When are you seeing it use CPU; when you are entering one of the functions or all of the time? Even spamming the "Delete Similar" button I could not drive the CPU usage above 8%. youtuber 1 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
youtuber Posted May 17, 2017 Author Share Posted May 17, 2017 Example of a student's dictionary Add it and try it http://pasted.co/b901c451 Link to comment Share on other sites More sharing options...
kylomas Posted May 18, 2017 Share Posted May 18, 2017 Add it where and how? Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
UEZ Posted May 18, 2017 Share Posted May 18, 2017 It is related to Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
kylomas Posted May 18, 2017 Share Posted May 18, 2017 youtuber, You want to operate on 50 K+ (478K bytes) entries using edit controls and array udf's. Even after you add guictrlsetlimit statements to get the edit controls to load you will have terrible response time. You need to use a DB or possibly a dictionary object as your access mechanism. If you define what you are trying to do we can help with that. I tried your code like this... expandcollapse popup#include <Array.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Dim $aEditRead $Form1 = GUICreate("Form1", 581, 352, 192, 125) $Edit1 = GUICtrlCreateEdit("", 24, 32, 145, 225) guictrlsetlimit($Edit1,1000000000) ; <------ increase limit ;GUICtrlSetData(-1, "Autoit" & @CRLF & "autoit" & @CRLF & "autoitscript" & @CRLF & "autoitscript" & @CRLF & "123" & @CRLF & "123" & @CRLF & "Autoitscript" & @CRLF & "autoitscript.com" & @CRLF & "autoitscript.coM" & @CRLF & "Autoitscript" & @CRLF & "123a" & @CRLF & "123A" & @CRLF & "AutoitscripT") $Edit2 = GUICtrlCreateEdit("" & @CRLF, 184, 32, 145, 225, BitOR($ES_MULTILINE, $ES_AUTOVSCROLL, $WS_VSCROLL)) GUICtrlSetData(-1, "") $Button1 = GUICtrlCreateButton("Delete similar", 24, 296, 70, 33) $Label2 = GUICtrlCreateLabel("", 208, 272, 46, 17) $Button2 = GUICtrlCreateButton("Copy", 200, 296, 75, 33) $Edit3 = GUICtrlCreateEdit("" & @CRLF, 344, 32, 185, 225, BitOR($ES_MULTILINE, $ES_AUTOVSCROLL, $WS_VSCROLL)) $Label1 = GUICtrlCreateLabel("Similar ones", 368, 272, 97, 24) GUISetState(@SW_SHOW) ; load edit control local $adict = stringregexp(fileread(@scriptdir & '\dict.txt'),'.*\R',3) for $1 = 0 to ubound($adict) - 1 guictrlsetdata($edit1,$adict[$1],1) next ; end load edit control While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 _deletesimilar() EndSwitch WEnd Func _deletesimilar() $aEditRead = StringSplit(StringStripCR(GUICtrlRead($Edit1)), @LF,2) $aUniques=_ArrayUnique($aEditRead, 0, 0, 1) $aUniques2=_ArrayUnique($aEditRead) For $i = 1 To UBound($aUniques) - 1 $aPos = _ArrayFindAll($aEditRead, $aUniques[$i], 0, 0, 1) If UBound($aPos) > 1 Then GUICtrlSetData($Edit2, $aUniques[$i] & @CRLF, 1) Next GUICtrlSetData($Label2, "Deleted") Dim $aSimilar[UBound($aEditRead)] $c = 0 For $i = 1 To UBound($aUniques2) - 1 $aPos = _ArrayFindAll($aEditRead, $aUniques2[$i]) If UBound($aPos) > 0 Then For $j = 0 To UBound($aPos) - 1 $aSimilar[$c] = $aEditRead[$aPos[$j]] $c += 1 Next EndIf Next ReDim $aSimilar[$c] $aUniques3=_ArrayUnique($aSimilar, 0, 0, 1) _ArraySort($aUniques3) For $i = 1 to UBound($aUniques3) - 1 GUICtrlSetData($Edit3, $aUniques3[$i] & @CRLF, 1) Next EndFunc and the response is terrible. kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
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