private string NativeBindingTest(int count) { var target = new TestModel { Visible = true }; var model = new BindingPerformanceModel(target); target.DataBindings.Add("Value", model, "Property", false, DataSourceUpdateMode.OnPropertyChanged); Controls.Add(target); Stopwatch startNew = Stopwatch.StartNew(); for (int i = 0; i < count; i++) target.Value = i % 2 == 0 ? "0" : "1"; startNew.Stop(); Controls.Remove(target); if (model.SetCount != count) throw new Exception(); return startNew.Elapsed.ToString(); }
private string MugenBindingExpTest(int count) { var target = new TestModel(); var model = new BindingPerformanceModel(target); target.Bind(() => m => m.Value) .To(model, () => (vm, ctx) => (vm.Property ?? string.Empty).Length + vm.Property) .Build(); Controls.Add(target); Stopwatch startNew = Stopwatch.StartNew(); for (int i = 0; i < count; i++) model.Property = i % 2 == 0 ? "0" : "1"; startNew.Stop(); Controls.Remove(target); if (model.SetCount != count) throw new Exception(); return startNew.Elapsed.ToString(); }
private string NoBindingTest(int count) { var target = new TestModel(); var model = new BindingPerformanceModel(target); target.ValueChanged += (sender, args) => model.Property = ((TestModel)sender).Value; Controls.Add(target); Stopwatch startNew = Stopwatch.StartNew(); for (int i = 0; i < count; i++) target.Value = i % 2 == 0 ? "0" : "1"; startNew.Stop(); Controls.Remove(target); if (model.SetCount != count) throw new Exception(); return startNew.Elapsed.ToString(); }
private string NoBindingTest(int count) { var target = new TestModel(); var model = new BindingPerformanceModel(target); Controls.Add(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(); Controls.Remove(target); if (model.SetCount != count) throw new Exception(); return startNew.Elapsed.ToString(); }