ListIconGadget Performance Problem

Everything else that doesn't fall into one of the other PB categories.
ebs
Enthusiast
Enthusiast
Posts: 567
Joined: Fri Apr 25, 2003 11:08 pm

ListIconGadget Performance Problem

Post 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
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Can we see the code?
I may look like a mule, but I'm not a complete ass.
Marco2007
Enthusiast
Enthusiast
Posts: 648
Joined: Tue Jun 12, 2007 10:30 am
Location: not there...

Post 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
PureBasic for Windows
User avatar
Michael Vogel
Addict
Addict
Posts: 2867
Joined: Thu Feb 09, 2006 11:27 pm
Contact:

Post 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
ebs
Enthusiast
Enthusiast
Posts: 567
Joined: Fri Apr 25, 2003 11:08 pm

Post 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
Perkin
Enthusiast
Enthusiast
Posts: 504
Joined: Thu Jul 03, 2008 10:13 pm
Location: Kent, UK

Post 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
%101010 = $2A = 42
dige
Addict
Addict
Posts: 1432
Joined: Wed Apr 30, 2003 8:15 am
Location: Germany
Contact:

Post by dige »

If you use the PureLVSORT Lib, you should also disable it during
AddgadgetItems...

PureLVSORT_Disabled(#True|#False)
Post Reply