Пример #1
0
        public void testInvoke()
        {
            var argTypes = new Type[1];

            argTypes[0] = typeof(TestMsg);

            var mi = GetType().GetMethod("handle", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, argTypes, null);

            var o = new TestMsg();

            var timer = new lib.Timer();

            var args = new object[1];

            args[0] = o;

            timer.Start();
            for (int i = 0; i < m_runCount; ++i)
            {
                mi.Invoke(this, args);
            }
            var endMs = timer.Current;

            log.info($"testInvoke: {endMs}");
        }
Пример #2
0
        public void testExpression()
        {
            var args = new Type[1];

            args[0] = typeof(TestMsg);

            var mi = GetType().GetMethod("handle", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, args, null);

            ParameterExpression pe = Expression.Parameter(typeof(TestMsg), "msgIn");

            var exConvert = Expression.Convert(pe, args[0]);

            var exParams = new Expression[1];

            exParams[0] = exConvert;

            var exThis = Expression.Constant(this);
            var exCall = Expression.Call(exThis, mi, exParams);

            var fn = Expression.Lambda <Action <TestMsg> >(exCall, pe).Compile();

            var o = new TestMsg();

            var timer = new lib.Timer();

            timer.Start();
            for (int i = 0; i < m_runCount; ++i)
            {
                fn(o);
            }
            var endMs = timer.Current;


            log.info($"testExpression: {endMs}");
        }
Пример #3
0
        public void testDirect()
        {
            var o = new TestMsg();

            var timer = new lib.Timer();

            timer.Start();
            for (int i = 0; i < m_runCount; ++i)
            {
                handle(o);
            }
            var endMs = timer.Current;

            log.info($"testDirect: {endMs}");
        }