views:

33

answers:

1

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?

+2  A: 

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.

Timores
Interesting. So if we're talking about several hundred of such bindings being set up, its conceivable that the wiring up of those listening events eat up cpu cycles upon creating the window. So it could be that it there is a speed and memory hit, correct?
Kilhoffer
Correct, I was discounting the time needed for this connection setup , but with thousands of them, they may matter.
Timores
A one-way binding still listens to the source for change notification - a one-time binding doesn't.
jeffora
@jeffora, Oops, you're correct, I must stop eating these new mushrooms. It should prevent me from mixing up OneWay and OneWayToSource.
Timores
Ah, very nice. Thanks for the update and thanks for pointing that out, jeffora.
Kilhoffer
@Timores: Yes, we've profiled the app and found the largest bottleneck to be the creation of controls when scrolling through a large list. Virtualization had little or no effect, too. So we started looking at speeding up databinding.
Kilhoffer