コード例 #1
0
ファイル: PropertyAccess.cs プロジェクト: hahanonym/nesper
        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);
            }
        }
コード例 #2
0
ファイル: PropertyAccess.cs プロジェクト: hahanonym/nesper
        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);
            }
        }
コード例 #3
0
ファイル: PerforatorMain.cs プロジェクト: qinfengzhu/nesper
        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);
            }
        }
コード例 #4
0
ファイル: PerforatorMain.cs プロジェクト: ecakirman/nesper
        private static void PerformanceTestQuery()
        {
            var statementArray = new[]
            {
                //TextWinLengthWithGroup,
                //TextWinLength,
                //TextAggregationWithTimeWindow,
                //TextAggregationWithNoWindow,
                //TextWithPropertyNames,
                TextWithWildcard,
            };

            var statementActions = new Runnable[]
            {
                //TestWinLengthWithGroup,
                //TestWinLength,
                //TestAggregationWithTimeWindow,
                //TestAggregationWithNoWindow,
                //TestWithPropertyNames,
                TestWithWildcard,
            };

            for (int nn = 0; nn < statementArray.Length; nn++)
            {
                string   statementText   = statementArray[nn];
                Runnable statementAction = statementActions[nn];
                //Console.WriteLine("=>> {0}", statementText);

                SetupEPL(statementText);

                for (int ii = 0; ii <= 0; ii++)
                {
                    _eventCounter = 0;

                    var eventTime  = (decimal)PerformanceObserver.TimeMicro(statementAction);
                    var eventCount = (decimal)_eventCounter;

                    Console.WriteLine("Measurements done at {0} threads", ThreadCount);
                    Console.WriteLine("\t{0:N0} events", eventCount);
                    Console.WriteLine("\t{0:N0} microseconds", eventTime);
                    Console.WriteLine("\t{0:N3} events per second", eventCount * 1000000.0m / eventTime);
                }

                Console.WriteLine();
            }
        }
コード例 #5
0
ファイル: PropertyAccess.cs プロジェクト: hahanonym/nesper
        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);
            }
        }
コード例 #6
0
        public void TestSensorQuery()
        {
            var config = SupportConfigFactory.GetConfiguration();

            config.AddEventType("Sensor", typeof(Sensor));
            var epService = EPServiceProviderManager.GetDefaultProvider(config);

            epService.Initialize();

            var useGroup = true;
            var listener = new SupportUpdateListener();

            if (useGroup)
            {
                // 0.69 sec for 100k
                var stmtString = "select * from Sensor.std:groupwin(type).win:length(10000000).stat:weighted_avg(measurement, confidence)";
                //String stmtString = "SELECT * FROM Sensor.std:groupwin(type).win:length(1000).stat:weighted_avg('measurement','confidence')";
                var stmt = epService.EPAdministrator.CreateEPL(stmtString);
                stmt.AddListener(listener);
            }
            else
            {
                // 0.53 sec for 100k
                for (var i = 0; i < 10; i++)
                {
                    var stmtString = "SELECT * FROM Sensor(type='A" + i + "').win:length(1000000).stat:weighted_avg(measurement,confidence)";
                    var stmt       = epService.EPAdministrator.CreateEPL(stmtString);
                    stmt.AddListener(listener);
                }
            }

            // prime
            for (var i = 0; i < 100; i++)
            {
                epService.EPRuntime.SendEvent(new Sensor("A", "1", i, i));
            }

            // measure
            var numEvents = 10000L;
            var delta     = PerformanceObserver.TimeMicro(
                () =>
            {
                for (var i = 0; i < numEvents; i++)
                {
                    //int modulo = i % 10;
                    var modulo = 1;
                    var type   = "A" + modulo;
                    epService.EPRuntime.SendEvent(new Sensor(type, "1", i, i));

                    if (i % 1000 == 0)
                    {
                        //System.out.println("Send " + i + " events");
                        listener.Reset();
                    }
                }
            });

            // System.out.println("delta=" + delta);
            Assert.That(delta, Is.LessThan(1000000));

            epService.Dispose();
        }