Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Collection type with key for fast lookup but also itterated numericaly

Status
Not open for further replies.

Guern

Programmer
Jun 22, 2001
91
GB
Hi,

I'm trying to find a collection type with key that offers fast lookup but also can be itterated though in order of insertion. The reason fot this is I am using it as a first in first out object cache. The cache has maybe 30,000 items. I used the dictionary class but this eventualy becomes unstable and crashes as I run out of ram. I tested simple LIST which is better but I must itterate over every item to find my result. Speed is one 3rd of the dictionary. I tried standard collections and keys, but performance is abismal.

So, is there a somthing in between? I cant find anything.

I want to be able to do a quick search for the key and also remove an item that was the oldest in order to add the new item. With an array that's easy. Drop the first, add to the end. Doesn't seem possible with dictionary without storing a value and itterating over all the data.

Performance I got with dict was 1300 per second, with list, 337 per second, with collection, 10 per sec (!), and with collection key, 79 per second.

Anyone got any ideas?

Thanks.
 
Hi Geurn,

At this point I dont know why but the performance you are getting is dire ... I develop on a rubbish PC running Vista Business (deliberately so my apps are not flattered by the dev PC) and I cannot reproduce these results.

You should be able to create your own collection object and achieve much better performance than that. I have just set up a 30,000 entry string/string dictionary and searched the keys collection in less than a second on my rubbish Vista ...

Can you provide some code.

DarkConsultant

Live long and prosper \\//
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top