简体   繁体   中英

Performance overhead on WPF virtualization

I have WPF app. There are few windows (each is working in its own thread) 5 - 10 windows. Each has only one significant control (which is data grid). Each data grid has 2000-3000 rows and 5 columns. Each row data bound to an item and when item's properties change the UI changes a lot (90% of the changes are - text, foreground, background). There are a 1000 changes per sec across all the windows.

If I switch virualization to Recycling the application consumes 35-40% less memory.

However I am guess that if the containers arent recycled the code must ran faster (since .NET wont need to re-bind containers and re-evaluate dep props and may be more).

Has anyone tried to investigate this in depth?

Is there performance hit/advantage in using containers recycling ( however small it is I need to know).

EDIT: The items which get updates are 95% are visible (in other words if a row is invisible there is 99% chance it isnt going to be updated). Also grid rows content/number never change. Only text and colours change in the cells. The rows always stay the same.

The fact that you use 1/3 less memory will probably result in a performance improvement in itself, due to better memory cache utilization and less garbage collection.

In addition, if a datagrid with over 2000 rows isn't virtualized, an update to any one of those rows needs to be propagated to the view. If it is virtualized, only rows that are visible on screen (and some buffer rows) need to be updated when changed.

Filling 2000 rows will take time. When virtualized, only a handful of rows need to be filled when data arrives, the other rows are filled when scrolling. If it isn't virtualized, less work needs to be done when scrolling, but more nees to be done when initializing.

But the real question is: is that extra work when scrolling visible? How many frames per second do you get when scrolling? Do you see slow UI updates? If not, virtualize.

It's a classic trade-off between memory usage and CPU usage, between fast initialization and somewhat slower scrolling on the one hand, and slow initialization and faster scrolling on the other.

Compare and measure, and see what works best for you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM