WeMartiansAreFriendly Posted September 22, 2008 Share Posted September 22, 2008 (edited) I've always thought some of the _GUICtrlListView_xxx functions were kind of slow, so after playing around, I've noticed a HUGE speed performance when using hWnd instead Control IDs. Here's an example where I simply rewrote "_GUICtrlListView_DeleteAllItems" to utilize GUICtrlGetHandle()..I created 1200 items, then deleted them here's what I got (in milliseconds)speed for original: 551.475676377864speed for modified: 9.26290911275036Hmm... Exampleexpandcollapse popup#include <GuiListView.au3> #include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <WindowsConstants.au3> $Form2 = GUICreate("FEEL THE SPEED", 413, 298, 303, 219) $ListView1 = GUICtrlCreateListView("Test1|Test2", 8, 16, 394, 206) $Button1 = GUICtrlCreateButton("Create", 16, 232, 75, 25, 0) $Button2 = GUICtrlCreateButton("Delete (with Original UDF)", 176, 232, 171, 25, 0) $Button3 = GUICtrlCreateButton("Delete (with Modified UDF)", 176, 264, 171, 25, 0) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 For $i = 1 to 1200 GUICtrlCreateListViewItem("Test1" & $i & "|Test2" & $i, $ListView1) Next Case $Button2 $timer = TimerInit() _GUICtrlListView_DeleteAllItems_ORIGINAL($ListView1) ConsoleWrite("speed for original: :" & TimerDiff($timer) &@lf) Case $Button3 $timer = TimerInit() _GUICtrlListView_DeleteAllItems_MODIFIED($ListView1) ConsoleWrite("speed for modified: " & TimerDiff($timer) &@lf) EndSwitch WEnd ; orginal (included with Autoit) Func _GUICtrlListView_DeleteAllItems_ORIGINAL($hWnd) If $Debug_LV Then _GUICtrlListView_ValidateClassName($hWnd) Local $ctrlID, $index If _GUICtrlListView_GetItemCount($hWnd) == 0 Then Return True If IsHWnd($hWnd) Then Return _SendMessage($hWnd, $LVM_DELETEALLITEMS) <> 0 Else ; this part seems to be SLOOOOOOOOOOW For $index = _GUICtrlListView_GetItemCount($hWnd) - 1 To 0 Step -1 $ctrlID = _GUICtrlListView_GetItemParam($hWnd, $index) If $ctrlID Then GUICtrlDelete($ctrlID) Next If _GUICtrlListView_GetItemCount($hWnd) == 0 Then Return True EndIf Return False EndFunc ;==>_GUICtrlListView_DeleteAllItems ; modified! ;You could also just use: _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($ListView)) Func _GUICtrlListView_DeleteAllItems_MODIFIED($hWnd) If $Debug_LV Then _GUICtrlListView_ValidateClassName($hWnd) Local $ctrlID, $index If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd) If _GUICtrlListView_GetItemCount($hWnd) == 0 Then Return True Return _SendMessage($hWnd, $LVM_DELETEALLITEMS) <> 0 EndFunc ;==>_GUICtrlListView_DeleteAllItems Edited September 22, 2008 by mrRevoked Ascer 1 Don't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet() Link to comment Share on other sites More sharing options...
gseller Posted September 22, 2008 Share Posted September 22, 2008 WOW, that is a significant difference.. Thanx! Link to comment Share on other sites More sharing options...
WeMartiansAreFriendly Posted September 22, 2008 Author Share Posted September 22, 2008 WOW, that is a significant difference.. Thanx!You're welcome! Don't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet() Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted September 22, 2008 Share Posted September 22, 2008 I didn't know the difference was that big, thx for informing! .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
arcker Posted September 22, 2008 Share Posted September 22, 2008 i've constated it when i've used paulia functions and then autoit conversions of them => i've reprogrammed all of the function to make it fast. maybe a paramter would be better in those function instead of let the function choose if it's a hwnd or not. -- Arck System _ Soon -- Ideas make everything "La critique est facile, l'art est difficile" Projects :[list] [*]Au3Service : Run your exe as service V3 / Updated 29/07/2013 Get it Here [/list] Link to comment Share on other sites More sharing options...
Zedna Posted September 22, 2008 Share Posted September 22, 2008 I use _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($ListView)) for simplicify (not for perfomance) too. But in this case all control IDs (for listview items created by GUICtrlCreateListviewItem) remain undeleted (memory leak). So this is not exactly right concept. Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
ptrex Posted September 22, 2008 Share Posted September 22, 2008 @mrRevoked This very good to know !! Because this could be the case with other controls as well. Thanks, ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
arcker Posted September 22, 2008 Share Posted September 22, 2008 this is the case for all of the control functions that verify the hwnd of the parameter. -- Arck System _ Soon -- Ideas make everything "La critique est facile, l'art est difficile" Projects :[list] [*]Au3Service : Run your exe as service V3 / Updated 29/07/2013 Get it Here [/list] Link to comment Share on other sites More sharing options...
WeMartiansAreFriendly Posted September 26, 2008 Author Share Posted September 26, 2008 (edited) I use _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($ListView)) for simplicify (not for perfomance) too. But in this case all control IDs (for listview items created by GUICtrlCreateListviewItem) remain undeleted (memory leak). So this is not exactly right concept. Well, thanks for pointing that out, you're absolutely right, the memory usage keeps growing. I've written somewhat of an alternative to GUICtrlCreateListviewItem. Some strange observations, using a handle instead of an ID for _GUICtrlListView_CreateItem() is significantly slower while the opposite is true for _GUICtrlListView_DeleteAllItems. expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> $Form2 = GUICreate("Example", 413, 298, 303, 219) $ListView = GUICtrlCreateListView("Test1|Test2", 8, 16, 394, 206) $Button1 = GUICtrlCreateButton("Create", 16, 232, 75, 25, 0) $Button2 = GUICtrlCreateButton("Delete All", 176, 232, 171, 25, 0) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 $timer = TimerInit() For $i = 1 to 1200 _GUICtrlListView_CreateItem($ListView, "Test1" & $i &"|"& "Test2"& $i) Next ConsoleWrite("creation speed: :" & TimerDiff($timer) &@lf) Case $Button2 $hListView = GUICtrlGetHandle($ListView); get the handle to the list view $timer = TimerInit() _GUICtrlListView_DeleteAllItems($hListView) ConsoleWrite("deletion speed: :" & TimerDiff($timer) &@lf) EndSwitch WEnd ; #FUNCTION# ==================================================================================================== ================ ; Name...........: _GUICtrlListView_CreateItem() ; Description ...: Creates a list view item with subitems ; Syntax.........: _GUICtrlListView_CreateItem($hListView, $sItem) ; Parameters ....: $hListView - Handle to the control ; $sItemText - Item text (string delimited) ; Return values .: Success - Item Index ; Failure @error ; 1 - Item delimiter failed ; 2 - Failed to Add item ; 3 - Failed to Add sub item ; Author ........: mrRevoked ; Remarks .......: ; Related .......: _GUICtrlListView_AddItem, _GUICtrlListView_AddSubItem ; Link ..........; ; Example .......; Yes ; ==================================================================================================== Func _GUICtrlListView_CreateItem($hListView, $sItemText) Local $sDelim = Opt('GUIDataSeparatorChar') Local $aItem = StringSplit($sItemText, $sDelim) If $aItem[0] < 1 Then Return SetError(1, 0, 0) Local $iIndex = _GUICtrlListView_AddItem($hListView, $aItem[1]) If $iIndex < 0 Then Return SetError(2, 0, 0) For $i = 2 To $aItem[0] $iSubItem = _GUICtrlListView_AddSubItem($hListView, $iIndex, $aItem[$i], $i - 1) If $iSubItem = False Then Return SetError(3, 0, 0); don't want to be stuck inside a loop of fail. Next Return $iIndex EndFunc ;_GUICtrlListView_CreateItem Edited September 26, 2008 by mrRevoked Don't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet() 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