Esempio n. 1
0
        private static string NoBindingTest(int count)
        {
            var target = new TestModel();
            var model  = new BindingPerformanceModel(target);

            target.PropertyChanged += (sender, args) =>
            {
                if (args.PropertyName == "Value")
                {
                    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());
        }
Esempio n. 2
0
        private static string NativeBindingTest(int count)
        {
            var target  = new TestModel();
            var model   = new BindingPerformanceModel(target);
            var binding = new System.Windows.Data.Binding("Property")
            {
                Source = model,
                Mode   = BindingMode.TwoWay,
                ValidatesOnDataErrors       = false,
                ValidatesOnExceptions       = false,
                ValidatesOnNotifyDataErrors = false,
                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());
        }
Esempio n. 3
0
        private string NativeBindingTest(int count)
        {
            var target = new TestModel {
                Visible = true
            };
            var model = new BindingPerformanceModel(target);

            target.DataBindings.Add("Text", model, "Property", false, DataSourceUpdateMode.OnPropertyChanged);
            Controls.Add(target);

            Stopwatch startNew = Stopwatch.StartNew();

            for (int i = 0; i < count; i++)
            {
                target.Text = 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());
        }
Esempio n. 5
0
        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());
        }
Esempio n. 6
0
        private static string MugenBindingExpTest(int count)
        {
            var target = new TestModel();
            var model  = new BindingPerformanceModel(target);

            BindingServiceProvider.BindingProvider.CreateBindingsFromString(target,
                                                                            "Value (Property ?? $string.Empty).Length + Property", new object[] { model });

            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());
        }
Esempio n. 7
0
        private string MugenBindingTest(int count)
        {
            var target = new TestModel();
            var model  = new BindingPerformanceModel(target);

            BindingServiceProvider.BindingProvider.CreateBindingsFromString(target, "Value Property, Mode=TwoWay", new object[] { model });
            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 MugenBindingTest(int count)
        {
            var target = new TestModel(this);
            var model  = new BindingPerformanceModel(target);

            target.Bind(() => t => t.Value)
            .To(model, () => (m, ctx) => m.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());
        }
Esempio n. 9
0
        private static string NativeBindingTest(int count)
        {
            var target = new TestModel();
            var model  = new BindingPerformanceModel(target);

            target.BindingContext = model;
            var binding = new Xamarin.Forms.Binding("Property", BindingMode.TwoWay);

            target.SetBinding(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());
        }