New topic: 

Is an array faster than a Listbox ?

<http://forums.realsoftware.com/viewtopic.php?t=38355>

         Page 1 of 1
   [ 7 posts ]                 Previous topic | Next topic          Author  
Message        peterthisted          Post subject: Is an array faster than a 
Listbox ?Posted: Mon Mar 28, 2011 2:57 am                         
Joined: Mon Aug 14, 2006 7:12 am
Posts: 51                I am building an app that needs to be as fast as 
possible and use as less system resources as possible (arn't we all  )

Outside data comes from an external app using UDP datagram, which I then store 
in a Listbox 20 times a second. Afterwards I pick data as necessary 
My listbox is enabled but not visible, so it does not need to be redrawn. That 
alone speeds things up 

So I was wondering if an array would be better and faster (ex. dim 
ListboxArray(100,8) as string  )?

Re Peter   
                             Top                Specialised          Post 
subject: Re: Is an array faster than a Listbox ?Posted: Mon Mar 28, 2011 4:59 
am                                 
Joined: Thu Aug 26, 2010 6:57 am
Posts: 178
Location: Sydney Australia                For key/value pairs a dictionary is 
faster than either a listbox or an array.
I would not use a listbox for what you suggest.      
_________________
Regards

Chris Musty
Specialised Technologies Pty Ltd

Software | Electronics | IT | Multimedia

http://www.specialised.net.au
-----------------------------------------------
RB 2011r1 Enterprise on Win7 Ultimate, Ubuntu 10.10 on Virtualbox  
                             Top                 peterthisted          Post 
subject: Re: Is an array faster than a Listbox ?Posted: Mon Mar 28, 2011 5:25 
am                         
Joined: Mon Aug 14, 2006 7:12 am
Posts: 51                I am afraid i do not understand the answer 

Data coming in is not static but in my book a dictionary is ?

Re Peter

EDIT:  Maybe I should mention that my datagram is a MemoryBlock that is decoded 
before saving in the Listbox...   
                             Top                charonn0          Post subject: 
Re: Is an array faster than a Listbox ?Posted: Mon Mar 28, 2011 6:12 am         
                        
Joined: Mon Apr 02, 2007 2:08 am
Posts: 392
Location: San Francisco, CA, USA                The Dictionary class is 
designed for key=value pairs. It's not an actual dictionary like Websters or 
Oxford. An array would only work if both the key and value are the same 
datatype or can be cast into the same datatype without losing information.      
_________________
Boredom Software  
                             Top                mjh          Post subject: Re: 
Is an array faster than a Listbox ?Posted: Mon Mar 28, 2011 6:57 am             
                    
Joined: Sun Feb 19, 2006 3:10 pm
Posts: 1157
Location: Hamburg, Germany                peterthisted wrote:So I was wondering 
if an array would be better and faster (ex. dim ListboxArray(100,8) as string  
)?
While I have never actually compared using a ListBox versus an array, common 
sense would suggest that a ListBox requires more housekeeping than an array and 
would thus be much slower. In fact I would never have dreamed of using a 
ListBox for data storage – it is strictly for display purposes. (Btw., if the 
ListBox isn’t actually visible, it doesn’t need to be enabled either.)

So an array would probably be the best choice here. Dictionaries – in the RB 
sense as a data structure – are also quite fast, but probably less suited to 
your task.      
_________________
Michael J. Hußmann 
http://digicam-experts.de  
                             Top                jefftullin          Post 
subject: Re: Is an array faster than a Listbox ?Posted: Mon Mar 28, 2011 7:15 
am                                 
Joined: Wed Nov 15, 2006 3:50 pm
Posts: 2223
Location: England                I dont see the need for pairs, to be honest.
A collection does the trick here, surely?

data arrives and is added to the collection.
At the end of the process, you have a list of stuff.

VB coders used to use a listbox for this because the listbox had a sorted 
property.. you just threw stuff in and it came out sorted. The OP hasnt 
mentioned any need for sorting. (Yet)

If the data is discarded every 1/20 of a second, the collection can be cleared 
or newed as the equivalent of listbox1.items.clear   
                             Top                peterthisted          Post 
subject: Re: Is an array faster than a Listbox ?Posted: Mon Mar 28, 2011 8:55 
am                         
Joined: Mon Aug 14, 2006 7:12 am
Posts: 51                Thanks for the answers 

I did not know about the Dictionary Class, but it is nice to learn new stuff 
all the time.

My Listbox is a storage place for the decoded data and I perform a lot of 
lookup in the Listbox afterwards.
So, the Dictionary could be a much better and faster way to store and retrieve 
my data.

This said, the Listbox is a good way to develop and debug the app.
The data can be shown and hidden during debugging determining if the data has 
arrived and if the lookup has been performed correctly.

But now I have everything in place, so it is time to streamline the code.

Re Peter   
                             Top             Display posts from previous: All 
posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost 
timeSubject AscendingDescending          Page 1 of 1
   [ 7 posts ]      
-- 
Over 1500 classes with 29000 functions in one REALbasic plug-in collection. 
The Monkeybread Software Realbasic Plugin v9.3. 
http://www.monkeybreadsoftware.de/realbasic/plugins.shtml

[email protected]

Reply via email to