Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a performance benefit to explicitly specifying OneWay binding when setting up bindings in WPF?

A project I'm working on is suffering from some minor performance issues. Our team is performing many small improvements to achieve larger gains in performance. We've managed to help the application out some by making some more obvious changes, and we've looked to data binding to provide some additional improvements. I know the default binding mode is TwoWay, but most of our bindings do not require TwoWay binding. Would it be worth our time to go through and explicitly specify the Mode as OneWay where we've accepted the default?

like image 418
Kilhoffer Avatar asked Mar 08 '10 16:03

Kilhoffer


1 Answers

Sorry, 1st version is 100% wrong (thanks, @Jeffora). I keep it here, otherwise the comments don't make sense.

A one-way binding does not need to set up a connection with the source to listen for change notifications, so it requires less memory, but as far as speed is concerned, I don't imagine that there is a difference.

2nd version: Both OneWay and TwoWay bindings subscribe to the source for changes, in order to update the target property. So, the difference in performance is the update of the source property, which could have an impact, depending on what the rest of the software does when the update occurs.

If performance is critical and your scenario does not need target updates, using OneTime binding could be an option.

I take the opportunity of this correction to ask if you profiled your app, in order to find hotspots. The 80/20 rule (or event 90/10) is quite frequent, i.e. a small amount of code accounts for most of the time spent. Without knowing it, optimization efforts could get you no gain at all.

like image 200
Timores Avatar answered Oct 13 '22 21:10

Timores