Page 1 of 1

ListIconGadget Performance Problem

Posted: Wed Jul 29, 2009 5:31 pm
by ebs
I have a ListIconGadget with 18 columns. My program adds about 900 items, each about 200 characters long.
It takes over 80 seconds to add these items, in a tight loop, using this statement:

Code: Select all

AddGadgetItem(#ListIcon_FileInfo, -1, ItemString)
If I remove the statement that adds the item to the ListIconGadget, my program completes its processing in less than one second.

Can anyone suggest ways I can speed this up?
I have tried turning off the redraw of the gadget while filling it, but this has very little effect.
I have read here that ListIconGadgets are slow, but this seems excessive.
I have also seen some code by Sparkie that disables notifications when deleting items.
Is there something similar I could do when adding items?

Is there a better choice to display data in a grid that would give better performance?

Any suggestions would be greatly appreciated!

Thanks,
Eric

Posted: Wed Jul 29, 2009 6:01 pm
by srod
Can we see the code?

Posted: Wed Jul 29, 2009 6:14 pm
by Marco2007
....bloody fast:

Code: Select all

For i=0 To 19 
a$+LSet("", 200, Chr(65+i))+Chr(10) 
Next 
Debug Len(a$) 

  If OpenWindow(0, 216, 0, 600, 300, "listicon",  #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar ) 
      ListIconGadget(0, 15, 20, 565, 255, "Column0", 100) 
      For t=1 To 18 
      AddGadgetColumn(0, t, "Column1", 100) 
      Next 
      For j=0 To 900 
      AddGadgetItem(0, -1, a$) 
      Next 
  EndIf 

Repeat :Until WaitWindowEvent()=#WM_CLOSE

Posted: Wed Jul 29, 2009 6:21 pm
by Michael Vogel
80 seconds for adding only 900 values - seems quite unusual, I would add a debug line or just a counter to see if this part will be executed 900 times...

Michael

And here Marco's code again, just to show the tuning....

Code: Select all

For i=0 To 19
	a$+LSet("", 200, Chr(65+i))+Chr(10)
Next
Debug Len(a$)

If OpenWindow(0, 216, 0, 600, 300, "listicon",  #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar )
	ListIconGadget(0, 15, 20, 565, 255, "Column0", 100)

	SendMessage_(GadgetID(0),#WM_SETREDRAW,#False,0)

	For t=1 To 18
		AddGadgetColumn(0, t, "Column1", 100)
	Next
	For j=0 To 900
		AddGadgetItem(0, -1, a$)
	Next

	SendMessage_(GadgetID(0),#WM_SETREDRAW,#True,0)

EndIf

Repeat :Until WaitWindowEvent()=#WM_CLOSE

Posted: Wed Jul 29, 2009 8:36 pm
by ebs
A BIG thanks to everyone who replied!

Your examples made me review my code, and I remembered that I was using the LVSort library.
I didn't disable it when adding items to the ListIconGadget (like you're supposed to).
When I disabled and re-enabled it, the time went down from 80 seconds to under 4 seconds.

Thanks again,
Eric

Posted: Wed Jul 29, 2009 11:59 pm
by Perkin
@ebs if you're not using the 'SendMessage' lines as in post by Michael Vogel, add them as well, it will speed it up even more.

I had this prob before and couldn't believe the difference those lines make. :)

edit-spelling

Posted: Thu Jul 30, 2009 9:26 am
by dige
If you use the PureLVSORT Lib, you should also disable it during
AddgadgetItems...

PureLVSORT_Disabled(#True|#False)