levitali / CompiledBindings

MIT License
279 stars 14 forks source link

Is it faster than the bindings in the Xamarin Forms on Android for example? #13

Open opcodewriter opened 2 years ago

opcodewriter commented 2 years ago

First, congratulations for your library!

Is it faster than the bindings in the Xamarin Forms on Android for example? If yes, why, which are the improvements?

Thanks!

levitali commented 2 years ago

If you use standard compiled binding in Xamarin Forms, by setting the XamlCompilationAttribute and specifying x:DataType, than the performance in many cases is the same.

It can be in faster, because my compiled bindings are optimized for the whole binding scope (for example, for the whole Page).

If you have, for example, these two bindings:

<Label Text="{Binding ModifyViewModel.Model.Property1}"/>
<Label Text="{Binding ModifyViewModel.Model.Property2}"/>

than the Properties ModifiyViewModel and Model are evaluated (gotten) for every binding. With my compiled bindings, each Property is taken only once for all bindings in the scope. If a Property is not merely a wrapper for a field, and do some more logic to get the value, than it can effect performance.

opcodewriter commented 2 years ago

With my compiled bindings, each Property is taken only once for all bindings in the scope.

Do you mean that Forms subscribes twice, while your library subscribes once to the Model? In other words, does Forms do something like this:

viewModel.PropertyChanged += onProperty1Changed;
viewModel.PropertyChanged += onProperty2Changed;

while your library does:

viewModel.PropertyChanged += onPropertyChanged;