Exemplo n.º 1
0
        public static void MeasureMagic()
        {
            Console.WriteLine("Lambda(Magic)");

            var bidData       = new BidData("IBM", 0L, 0.50);
            var bidDataObject = (Object)bidData;

            var propInfo   = typeof(BidData).GetProperty("BidPrice");
            var methodInfo = propInfo.GetGetMethod();

            var lambda = MagicType.GetLambdaAccessor(methodInfo);

            for (int nn = 0; nn < 10; nn++)
            {
                var timeItem = PerformanceObserver.TimeMicro(
                    delegate
                {
                    for (int ii = 1000000; ii >= 0; ii--)
                    {
                        lambda.Invoke(bidDataObject);
                    }
                });

                Console.WriteLine("Lambda(Magic):  {0,8} {1,8:N3} {2,8:N3}", timeItem, timeItem / 1000000.0m, 1000000.0m / timeItem);
            }
        }
Exemplo n.º 2
0
        public static void MeasureNativeLambda()
        {
            Console.WriteLine("Lambda(Native)");

            var bidData       = new BidData("IBM", 0L, 0.50);
            var bidDataObject = (Object)bidData;

            Expression <Func <object, object> > lambdaExpression =
                arg => (object)((BidData)arg).BidPrice;

            Func <object, object> lambda = lambdaExpression.Compile();

            for (int nn = 0; nn < 10; nn++)
            {
                var timeItem = PerformanceObserver.TimeMicro(
                    delegate
                {
                    for (int ii = 1000000; ii >= 0; ii--)
                    {
                        lambda.Invoke(bidDataObject);
                    }
                });

                Console.WriteLine("Lambda(Native): {0,8} {1,8:N3} {2,8:N3}", timeItem, timeItem / 1000000.0m, 1000000.0m / timeItem);
            }
        }
Exemplo n.º 3
0
        public void SendBidEvent()
        {
            var bidEvent = new BidData(
                SymbolList[Rand.Next(SymbolList.Length)],
                0L,
                Rand.NextDouble());

            _espRuntime.SendEvent(bidEvent);
        }
Exemplo n.º 4
0
        private static void PerformanceTestIdentNode()
        {
            var bidData    = new BidData("IBM", 0L, 0.50);
            var identNode1 = new ExprIdentNodeImpl("BidPrice");

            var bidDataEventType  = _espServiceProvider.EventAdapterService.GetEventTypeByName("BidData");
            var streamTypeService = new StreamTypeServiceImpl(bidDataEventType, null, false, null);

            identNode1.Validate(
                new ExprValidationContext(
                    _container,
                    streamTypeService,
                    null,
                    null,
                    null,
                    null,
                    null,
                    null,
                    null,
                    null,
                    null,
                    -1,
                    null,
                    null,
                    null,
                    false,
                    false,
                    false,
                    false,
                    null,
                    false
                    ));

            var exprEvaluatorContext = (ExprEvaluatorContext)null;

            Console.WriteLine("IdentNode");

            for (var nn = 0; nn < 10; nn++)
            {
                var eventBean  = new BeanEventBean(bidData, bidDataEventType);
                var eventBeans = new EventBean[] { eventBean };
                var timeItem   = PerformanceObserver.TimeMicro(
                    delegate
                {
                    for (var ii = 1000000; ii >= 0; ii--)
                    {
                        identNode1.ExprEvaluator.Evaluate(
                            new EvaluateParams(eventBeans, false, exprEvaluatorContext));
                    }
                });

                Console.WriteLine("time: {0} {1:N3} {2:N3}", timeItem, timeItem / 1000000.0m, 1000000.0m / timeItem);
            }
        }
Exemplo n.º 5
0
        public static void MeasureNative()
        {
            Console.WriteLine("Native");

            var bidData       = new BidData("IBM", 0L, 0.50);
            var bidDataObject = (Object)bidData;

            for (int nn = 0; nn < 10; nn++)
            {
                var timeItem = PerformanceObserver.TimeMicro(
                    delegate
                {
                    for (int ii = 1000000; ii >= 0; ii--)
                    {
                        var bidPrice1 = (object)(((BidData)bidDataObject).BidPrice);
                    }
                });

                Console.WriteLine("Native:         {0,8} {1,8:N3} {2,8:N3}", timeItem, timeItem / 1000000.0m, 1000000.0m / timeItem);
            }
        }