Page 1 of 1
Speed Up Listicon Loading?
Posted: Sat Aug 03, 2019 9:26 am
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
Re: Speed Up Listicon Loading?
Posted: Sat Aug 03, 2019 10:56 am
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
Re: Speed Up Listicon Loading?
Posted: Sat Aug 03, 2019 2:29 pm
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
Re: Speed Up Listicon Loading?
Posted: Sat Aug 03, 2019 2:50 pm
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.
Re: Speed Up Listicon Loading?
Posted: Sat Aug 03, 2019 5:10 pm
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
Re: Speed Up Listicon Loading?
Posted: Sun Aug 04, 2019 1:43 am
by BarryG
Sirius-2337 wrote:you can use HideGadget(0, 1)
Won't the user wonder where their window item went?
Re: Speed Up Listicon Loading?
Posted: Sun Aug 04, 2019 12:13 pm
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
Re: Speed Up Listicon Loading?
Posted: Sun Aug 04, 2019 7:21 pm
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
Re: Speed Up Listicon Loading?
Posted: Mon Aug 05, 2019 10:26 am
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