private static string MugenBindingTest(int count) { var target = new TestModel(); var model = new BindingPerformanceModel(target); target.Bind(() => t => t.Value) .To(model, () => (vm, ctx) => vm.Property) .TwoWay() .Build(); Stopwatch startNew = Stopwatch.StartNew(); for (int i = 0; i < count; i++) target.Value = i%2 == 0 ? "0" : "1"; startNew.Stop(); if (model.SetCount != count) throw new Exception(); return startNew.Elapsed.ToString(); }
private static string NativeBindingTest(int count) { var target = new TestModel(); var model = new BindingPerformanceModel(target); var binding = new Windows.UI.Xaml.Data.Binding { Source = model, Mode = BindingMode.TwoWay, Path = new PropertyPath("Property"), UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged }; BindingOperations.SetBinding(target, TestModel.ValueProperty, binding); Stopwatch startNew = Stopwatch.StartNew(); for (int i = 0; i < count; i++) target.Value = i%2 == 0 ? "0" : "1"; startNew.Stop(); if (model.SetCount != count) throw new Exception(); return startNew.Elapsed.ToString(); }
private static string MugenBindingExpTest(int count) { var target = new TestModel(); var model = new BindingPerformanceModel(target); target.Bind(() => m => m.Value) .To(model, () => pm => (pm.Property ?? string.Empty).Length + pm.Property) .Build(); Stopwatch startNew = Stopwatch.StartNew(); for (int i = 0; i < count; i++) model.Property = i % 2 == 0 ? "0" : "1"; startNew.Stop(); if (model.SetCount != count) throw new Exception(); return startNew.Elapsed.ToString(); }
private static string NoBindingTest(int count) { var target = new TestModel(); var model = new BindingPerformanceModel(target); target.ValueChanged += (sender, args) => model.Property = ((TestModel)sender).Value; Stopwatch startNew = Stopwatch.StartNew(); for (int i = 0; i < count; i++) target.Value = i % 2 == 0 ? "0" : "1"; startNew.Stop(); if (model.SetCount != count) throw new Exception(); return startNew.Elapsed.ToString(); }
private static string NoBindingTest(int count) { var target = new TestModel(); var model = new BindingPerformanceModel(target); Stopwatch startNew = Stopwatch.StartNew(); for (int i = 0; i < count; i++) { string text = i % 2 == 0 ? "0" : "1"; target.Value = text; model.Property = text; } startNew.Stop(); if (model.SetCount != count) throw new Exception(); return startNew.Elapsed.ToString(); }