Speed Up Listicon Loading?

Just starting out? Need help? Post your questions and find answers here.
collectordave
Addict
Addict
Posts: 1309
Joined: Fri Aug 28, 2015 6:10 pm
Location: Portugal

Speed Up Listicon Loading?

Post by collectordave »

I have a database with over 800000 records in one table.

I want to load this tables data into a list icon.

I currently take each row returned from a query and form a string with columnName + chr(10) then add this to the list icon.

Works very well but takes a long time

Is there any trick or tip to load the ListIcon quickly or should I look towards breaking the table data into bite sized chunks loading each as they are needed?

Regards

CD
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.
BarryG
Addict
Addict
Posts: 3324
Joined: Thu Apr 18, 2019 8:17 am

Re: Speed Up Listicon Loading?

Post by BarryG »

collectordave wrote:should I look towards breaking the table data into bite sized chunks loading each as they are needed?
Definitely yes for 800000 items. That's so much data for a poor little ListIconGadget().

For smaller amounts of data and for Windows only, you can turn drawing of the gadget off while filling. Try this example below (that only uses 100000 items) with the "NoRedraw" variable set to 0 at first, and then set to 1 on the second run. My results were 43 seconds with 0, and only 5 seconds with 1.

Code: Select all

NoRedraw=0

OpenWindow(0,320,256,640,480,"ListIcon",#PB_Window_SystemMenu)
ListIconGadget(0,20,20,600,450,"Items",600)

If NoRedraw=1
  SendMessage_(GadgetID(0),#WM_SETREDRAW,0,0)
EndIf

start.q=ElapsedMilliseconds()
For i=1 To 100000
  AddGadgetItem(0,-1,Str(i))
Next
time.q=ElapsedMilliseconds()-start

If NoRedraw=1
  SendMessage_(GadgetID(0),#WM_SETREDRAW,1,0)
EndIf

Debug "Took "+Str(time)+" ms to fill"

Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow
collectordave
Addict
Addict
Posts: 1309
Joined: Fri Aug 28, 2015 6:10 pm
Location: Portugal

Re: Speed Up Listicon Loading?

Post by collectordave »

Thanks for the reply BarryG

Unfortunately I am writing for cross platform so no windows only.

I have been experimenting and 1000 record chunks seems to give a good trade off between speed and usefull data.

Cheers

CD
Last edited by collectordave on Sat Aug 03, 2019 2:51 pm, edited 1 time in total.
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.
User avatar
skywalk
Addict
Addict
Posts: 3999
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: Speed Up Listicon Loading?

Post by skywalk »

Yes, you don't want to load an entire database into a gadget! Use the scroll events to replace the currently viewed list. 10 or 20 rows. That is fast.
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
Sirius-2337
User
User
Posts: 53
Joined: Sat May 14, 2011 10:39 am

Re: Speed Up Listicon Loading?

Post by Sirius-2337 »

Instead of SendMessage_(GadgetID(0),#WM_SETREDRAW,0,0) you can use HideGadget(0, 1)

Code: Select all

NoRedraw=1

OpenWindow(0,320,256,640,480,"ListIcon",#PB_Window_SystemMenu)
ListIconGadget(0,20,20,600,450,"Items",600)

If NoRedraw=1
  HideGadget(0, 1)
EndIf

start.q=ElapsedMilliseconds()
For i=1 To 100000
  AddGadgetItem(0,-1,Str(i))
Next
time.q=ElapsedMilliseconds()-start

If NoRedraw=1
  HideGadget(0, 0)
EndIf

Debug "Took "+Str(time)+" ms to fill"

Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow
BarryG
Addict
Addict
Posts: 3324
Joined: Thu Apr 18, 2019 8:17 am

Re: Speed Up Listicon Loading?

Post by BarryG »

Sirius-2337 wrote:you can use HideGadget(0, 1)
Won't the user wonder where their window item went?
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4663
Joined: Sun Apr 12, 2009 6:27 am

Re: Speed Up Listicon Loading?

Post by RASHAD »

HideGadget() is a good alternative to #WM_SETREDRAW and cross platform as well
Use it to load the first 100 - 1000 items then use a thread to load the rest
Egypt my love
davido
Addict
Addict
Posts: 1890
Joined: Fri Nov 09, 2012 11:04 pm
Location: Uttoxeter, UK

Re: Speed Up Listicon Loading?

Post by davido »

@collectordave,

Have you tried ListEX by Thorsten1867?
On my MacBook it loads 800,000 lines in less than 5 seconds.

If you are interested try the link below:

viewtopic.php?p=533673#p533673
DE AA EB
collectordave
Addict
Addict
Posts: 1309
Joined: Fri Aug 28, 2015 6:10 pm
Location: Portugal

Re: Speed Up Listicon Loading?

Post by collectordave »

Cracked it with the GridEX module.

Loading 20 rows at a time.

Posted a quick DB viewer to demonstrate viewtopic.php?f=12&t=73329

Thanks for the replies.

CD
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.
Post Reply