Hello,
I'm new to UI programming in general, and smartphone UI programming in particular. I have a question relating to performance of listviews. I have a listview object that has around 200 items with 2 columns each. Displaying this takes quite a while when I test it via the emulator (unfortunately I don't have a WM 5.0 device to deploy to and test on) -- to the order of almost a minute before the listview is displayed the first time when run via VS. Also, my code switches between 2 different lists based on a hotkey being pressed. The second list has fewer items and displays fast, but whenever I clear the listview and reload the first list of 200 items, the performance is very slow.
I am implementing switching the display from one list to the other by calling Clear() on the listview object, and rebuilding the listview object. Therefore, I'm recreating 200 ListViewItems (with 2 subitems each) every time I want to display the first list. Is there a different recommended pattern if I want to achieve this faster Should I instead have 2 separate listview objects and show/hide them alternatively Will that not consume more memory since I have the listview objects constantly in memory
Please let me know if you need more information on what I'm doing.
Thanks,
ravi

Question on listview (re)population - performance issue
nblankton
1) There are no profilers unfortunately, but you can use a Stopwatch for measuring via code and certainly use the perf counters
http://www.danielmoth.com/Blog/2004/12/stopwatch.html
http://blogs.msdn.com/davidklinems/archive/2005/10/04/476988.aspx
Cheers
Daniel
kregger
Are you surrounding your listview updates with Begin/EndUpdate
The tradeoff between performance and memory is one that has to be evaluated for each case by measuring. Use two listviews and see if the perf benefit outweighs the extra memory.
You could also not populate the list with so many items on startup and implement some kind of load on demand. Further thoughts on that are here:
http://www.danielmoth.com/Blog/2005/02/listview-with-scroll-events-and.html
Note that measuring perf should always be done on real device. That is an area that the emulator will always be the wrong platform for final decisions.
Cheers
Daniel
InstantKarma
Questions:
1) Are there any profilers/APIs to use that would help with figuring out hotspots in my app Or do I have to resort to good old-fashioned timers (begintick() and endtick() stuff)
2) Is there some thumb rule factor/constant I can use to figure how much faster or slower my application will be on a device as opposed to the emulator running on my specific machine
thanks much!