Solve performance issue with WPF application [closed] Solve performance issue with WPF application [closed] wpf wpf

Solve performance issue with WPF application [closed]


This is really a comment and not an answer but not enough space in commment.

ObservableCollection way faster than List seemed counter intuitive to me as ObservableCollection implements iList.

I have a list of 660,000 words that I tested on a ListView (virtualizing). Created the collection types below and created buttons to switch the binding in code behind. All collections rendered instantaneously (the power of virtualiztion).

The variable is the time to create the collection and features you need from the collection. Used SQLdataReader to populate the collection. There is variability in the SQLdataReader. Ran each 10 times got repeatable results to 2 significant digits and I report the average to 3 significant digits. List beat ObservableCollection by about 400 milliseconds. Did not measure memory but List clearly is going to use less memory.

Milliseconds to load 660,000 strings averaging about 40 character each.

    1510 List    1780 Dictionary      1820 HashSet    1980 ObservableCollection    8000 SortedDictionary

In a very large collection HashSet would fair better than List. HashSet should beat Dictionary - those numbers are within the variability of this limited non-rigorous test.

It comes down to features. ObservableCollection supports dynamic insert and delete. If you need dynamic insert and delete then it is by far the best choice. If you don't need dynamic insert and delete then my experience is that List is a better choice (via iNotifyPropertyChanged of the ListItem List supports dynamic revision).

List retains the order the items are added. HashSet does not retain the order. Many factors in selecting which collection to use.http://geekswithblogs.net/BlackRabbitCoder/archive/2011/06/16/c.net-fundamentals-choosing-the-right-collection-class.aspx

Had a comment about access time to a single item. I accessed items [1],[100000],[200000],[300000],[400000],[500000],[600000] using List, ObservableCollection, and Dictionary. They were all 12 ms. Access time was a dead heat and repeatable.