Пример #1
0
        private static void PerformanceTest2()
        {
            var tracer = new StopwatchTracer();

            Binder.SetTracer(tracer);

            var action = new BindingAction <string>
            {
                Action = TestExecute
            };

            var ctx     = "abc";
            var binding = new Binding1
            {
                Action = () => action.Action(ctx)
            };

            IBinding binding2 = new Binding2 <string>
            {
                Action  = action,
                Context = ctx
            };

            var action3 = new BindingAction3
            {
                Action = x => TestExecute((string)x)
            };

            var binding3 = new Binding3
            {
                Action  = action3,
                Context = ctx
            };

            var sw = new Stopwatch();

            sw.Start();

            for (int i = 0; i < 100000000; ++i)
            {
                //binding.Action();
                //binding2.Execute();
                binding3.Execute();
            }

            sw.Stop();

            // expected result: 400ms on average workstation
            Console.WriteLine($"Total: {sw.ElapsedMilliseconds}ms");
            Console.WriteLine($"Bindings: {tracer.Elapsed.TotalMilliseconds}ms");
            Console.ReadLine();
        }
Пример #2
0
        public virtual Binding copyPredicateBinding(String varName, int operator_Renamed)
        {
            Binding b = getBinding(varName);

            if (b != null)
            {
                Binding2 b2 = new Binding2(operator_Renamed);
                b2.LeftRow   = b.LeftRow;
                b2.LeftIndex = b.LeftIndex;
                b2.VarName   = b.VarName;
                return(b2);
            }
            else
            {
                return(null);
            }
        }