コード例 #1
0
        public void TestOp()
        {
            Configuration config = SupportConfigFactory.GetConfiguration();

            config.EngineDefaults.ThreadingConfig.IsInternalTimerEnabled       = false;
            config.EngineDefaults.ExpressionConfig.IsUdfCache                  = false;
            config.EngineDefaults.ThreadingConfig.IsThreadPoolOutbound         = true;
            config.EngineDefaults.ThreadingConfig.ThreadPoolOutboundNumThreads = 5;
            config.AddEventType <SupportBean>();

            EPServiceProvider epService = EPServiceProviderManager.GetDefaultProvider(config);

            epService.Initialize();

            var         listener = new SupportListenerSleeping(200);
            EPStatement stmt     = epService.EPAdministrator.CreateEPL("select * from SupportBean");

            stmt.Events += listener.Update;

            long delta = PerformanceObserver.TimeMillis(
                delegate {
                for (int i = 0; i < 5; i++)
                {
                    epService.EPRuntime.SendEvent(new SupportBean());
                }
            });

            Assert.IsTrue(delta < 100, "Delta is " + delta);

            Thread.Sleep(1000);
            Assert.AreEqual(5, listener.NewEvents.Count);

            epService.Dispose();
        }
コード例 #2
0
        private void RunAssertionEventIndexPerformance(EPServiceProvider epService)
        {
            var epl = "create window MyRectangleWindow#keepall as (id string, rx double, ry double, rw double, rh double);\n" +
                      "insert into MyRectangleWindow select id, x as rx, y as ry, width as rw, height as rh from SupportSpatialEventRectangle;\n" +
                      "create index Idx on MyRectangleWindow( (rx, ry, rw, rh) mxcifquadtree(0, 0, 100, 100));\n" +
                      "@Name('out') on SupportSpatialAABB select mpw.id as c0 from MyRectangleWindow as mpw where rectangle(rx, ry, rw, rh).intersects(rectangle(x, y, width, height));\n";
            var deploymentId = epService.EPAdministrator.DeploymentAdmin.ParseDeploy(epl).DeploymentId;
            var listener     = new SupportUpdateListener();

            epService.EPAdministrator.GetStatement("out").Events += listener.Update;

            SendSpatialEventRectangles(epService, 100, 50);

            var delta = PerformanceObserver.TimeMillis(
                () => {
                for (var x = 0; x < 100; x++)
                {
                    for (var y = 0; y < 50; y++)
                    {
                        epService.EPRuntime.SendEvent(new SupportSpatialAABB("R", x, y, 0.5, 0.5));
                        Assert.AreEqual(
                            Convert.ToString(x) + "_" + Convert.ToString(y),
                            listener.AssertOneGetNewAndReset().Get("c0"));
                    }
                }
            });

            Assert.That(delta, Is.LessThan(3000));

            epService.EPAdministrator.DeploymentAdmin.Undeploy(deploymentId);
        }
コード例 #3
0
        public void TestSensorQuery()
        {
            Configuration config = SupportConfigFactory.GetConfiguration();

            config.AddEventType("Sensor", typeof(Sensor));
            EPServiceProvider epService = EPServiceProviderManager.GetProvider("testSensorQuery", config);

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

            if (useGroup)
            {
                // 0.69 sec for 100k
                String 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')";
                EPStatement stmt = epService.EPAdministrator.CreateEPL(stmtString);
                stmt.Events += listener.Update;
            }
            else
            {
                // 0.53 sec for 100k
                for (int i = 0; i < 10; i++)
                {
                    String      stmtString = "SELECT * FROM Sensor(type='A" + i + "').win:length(1000000).stat:weighted_avg(measurement,confidence)";
                    EPStatement stmt       = epService.EPAdministrator.CreateEPL(stmtString);
                    stmt.Events += listener.Update;
                }
            }

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

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

                    if (i % 1000 == 0)
                    {
                        //Console.Out.WriteLine("Send " + i + " events");
                        listener.Reset();
                    }
                }
            });

            // Console.Out.WriteLine("delta=" + delta);
            Assert.IsTrue(delta < 1000);

            epService.Dispose();
        }
コード例 #4
0
        public void TestInKeywordSingleIndexLookup()
        {
            string epl = "select s0.id as val from " +
                         "S0#keepall s0, " +
                         "S1#keepall s1, " +
                         "S2#keepall s2 " +
                         "where p00 in (p10, p20)";

            string[]    fields = "val".Split(',');
            EPStatement stmt   = _epService.EPAdministrator.CreateEPL(epl);

            stmt.Events += _listener.Update;

            for (int i = 0; i < 10000; i++)
            {
                _epService.EPRuntime.SendEvent(new SupportBean_S0(i, "P00_" + i));
            }
            _epService.EPRuntime.SendEvent(new SupportBean_S1(0, "x"));

            long delta = PerformanceObserver.TimeMillis(
                () =>
            {
                for (int i = 0; i < 1000; i++)
                {
                    _epService.EPRuntime.SendEvent(new SupportBean_S2(1, "P00_6541"));
                    EPAssertionUtil.AssertPropsPerRow(_listener.GetAndResetLastNewData(), fields, new object[][] { new object[] { 6541 } });
                }
            });

            Assert.That(delta, Is.LessThan(500));
            Log.Info("delta=" + delta);
        }
コード例 #5
0
        public void Run(RegressionEnvironment env)
        {
            string methodName = ".testPerfPropertyAccess";

            string joinStatement = "@Name('s0') select * from " +
                                   "SupportBeanCombinedProps#length(1)" +
                                   " where Indexed[0].Mapped('a').Value = 'dummy'";

            env.CompileDeploy(joinStatement).AddListener("s0");

            // Send events for each stream
            SupportBeanCombinedProps theEvent = SupportBeanCombinedProps.MakeDefaultBean();

            log.Info(methodName + " Sending events");

            var delta = PerformanceObserver.TimeMillis(
                () => {
                for (int i = 0; i < 10000; i++)
                {
                    SendEvent(env, theEvent);
                }

                log.Info(methodName + " Done sending events");
            });

            log.Info(methodName + " delta=" + delta);

            // Stays at 250, below 500ms
            Assert.That(delta, Is.LessThan(1000));

            env.UndeployAll();
        }
コード例 #6
0
        private static void TryOptimizableEquals(
            RegressionEnvironment env,
            RegressionPath path,
            string epl,
            int numStatements)
        {
            // test function returns lookup value and "Equals"
            for (int i = 0; i < numStatements; i++) {
                string text = "@Name('s" + i + "') " + epl.Replace("!NUM!", i.ToString());
                env.CompileDeploy(text, path).AddListener("s" + i);
            }

            env.Milestone(0);

            var loops = 1000;
            var delta = PerformanceObserver.TimeMillis(
                () => {
                    SupportStaticMethodLib.ResetCountInvoked();
                    for (int i = 0; i < loops; i++) {
                        env.SendEventBean(new SupportBean("E_" + i % numStatements, 0));
                        SupportListener listener = env.Listener("s" + i % numStatements);
                        Assert.IsTrue(listener.GetAndClearIsInvoked());
                    }
                });

            Assert.AreEqual(loops, SupportStaticMethodLib.CountInvoked);

            Assert.IsTrue(delta < 1000, "Delta is " + delta);
            env.UndeployAll();
        }
コード例 #7
0
        public void Test1Stream2HistInnerJoinPerformance()
        {
            const string expression =
                "select s0.id as id, h0.val as valh0, h1.val as valh1 " +
                "from SupportBeanInt.std:lastevent() as s0, " +
                "method:SupportJoinMethods.FetchVal('H0', 100) as h0, " +
                "method:SupportJoinMethods.FetchVal('H1', 100) as h1 " +
                "where h0.index = p00 and h1.index = p00";

            var stmt = _epService.EPAdministrator.CreateEPL(expression);

            _listener    = new SupportUpdateListener();
            stmt.Events += _listener.Update;

            var fields = "id,valh0,valh1".Split(',');
            var random = new Random();

            long delta = PerformanceObserver.TimeMillis(
                delegate
            {
                for (int i = 1; i < 5000; i++)
                {
                    int num = random.Next(98) + 1;
                    SendBeanInt("E1", num);

                    var result = new Object[][] { new Object[] { "E1", "H0" + num, "H1" + num } };
                    EPAssertionUtil.AssertPropsPerRow(_listener.GetAndResetLastNewData(), fields, result);
                }
            });

            stmt.Dispose();
            _listener.Reset();
            Assert.That(delta, Is.LessThan(1000), "Delta to large, at " + delta + " msec");
        }
コード例 #8
0
        private void SendClockingInternal()
        {
            // Change to perform a long-running tests, each loop is 1 second
            int LOOP_COUNT = 2;
            int loopCount  = 0;

            while (true)
            {
                log.Info("Sending batch " + loopCount);

                // send events
                var delta = PerformanceObserver.TimeMillis(() =>
                {
                    for (int i = 0; i < 5000; i++)
                    {
                        double price = 50 + 49 * random.Next(100) / 100.0;
                        SendEvent(price);
                    }
                });

                // sleep remainder of 1 second
                if (delta < 950)
                {
                    Thread.Sleep(950 - (int)delta);
                }

                listener.Reset();
                loopCount++;
                if (loopCount > LOOP_COUNT)
                {
                    break;
                }
            }
        }
コード例 #9
0
        public void TestInKeywordSingleIndexLookup()
        {
            const string epl = "select IntPrimitive as val from SupportBean.win:keepall() sb, SupportBean_S0 s0 unidirectional " +
                               "where sb.TheString in (s0.p00, s0.p01)";

            string[]    fields = "val".Split(',');
            EPStatement stmt   = _epService.EPAdministrator.CreateEPL(epl);

            stmt.Events += _listener.Update;

            for (int i = 0; i < 10000; i++)
            {
                _epService.EPRuntime.SendEvent(new SupportBean("E" + i, i));
            }

            long delta = PerformanceObserver.TimeMillis(
                () =>
            {
                for (int i = 0; i < 1000; i++)
                {
                    _epService.EPRuntime.SendEvent(new SupportBean_S0(1, "E645", "E8975"));
                    EPAssertionUtil.AssertPropsPerRow(
                        _listener.GetAndResetLastNewData(), fields, new object[][] { new object[] { 645 }, new object[] { 8975 } });
                }
            });

            Assert.That(delta, Is.LessThan(500));
            Log.Info("delta=" + delta);
        }
コード例 #10
0
        public void TestOrPerformance()
        {
            foreach (var clazz in new Type[] { typeof(SupportBean) })
            {
                _epService.EPAdministrator.Configuration.AddEventType(clazz);
            }
            var listener = new SupportUpdateListener();

            for (var i = 0; i < 1000; i++)
            {
                var epl = "select * from SupportBean(TheString = '" + i + "' or IntPrimitive=" + i + ")";
                _epService.EPAdministrator.CreateEPL(epl).AddListener(listener);
            }

            var delta = PerformanceObserver.TimeMillis(
                () =>
            {
                Debug.WriteLine("Starting {0}", DateTime.Now.Print());

                for (var i = 0; i < 10000; i++)
                {
                    _epService.EPRuntime.SendEvent(new SupportBean("100", 1));
                    Assert.IsTrue(listener.IsInvoked);
                    listener.Reset();
                }

                Debug.WriteLine("Ending {0}", DateTime.Now.Print());
            });

            Debug.WriteLine("Delta={0}", delta + " msec");
            Assert.IsTrue(delta < 500);
        }
コード例 #11
0
        public void TestInKeywordMultiIndexLookup()
        {
            const string epl = "select id as val from SupportBean_S0.win:keepall() s0, SupportBean sb unidirectional " +
                               "where sb.TheString in (s0.p00, s0.p01)";

            string[]    fields = "val".Split(',');
            EPStatement stmt   = _epService.EPAdministrator.CreateEPL(epl);

            stmt.Events += _listener.Update;

            for (int i = 0; i < 10000; i++)
            {
                _epService.EPRuntime.SendEvent(new SupportBean_S0(i, "p00_" + i, "p01_" + i));
            }

            long delta = PerformanceObserver.TimeMillis(
                () =>
            {
                for (int i = 0; i < 1000; i++)
                {
                    _epService.EPRuntime.SendEvent(new SupportBean("p01_645", 0));
                    EPAssertionUtil.AssertProps(
                        _listener.AssertOneGetNewAndReset(), fields, new object[]
                    {
                        645
                    });
                }
            });

            Assert.That(delta, Is.LessThan(500));
            Log.Info("delta=" + delta);
        }
コード例 #12
0
        public void RunAssertion(String epl, int numLoops, AssertionCallback assertionCallback)
        {
            String[] fields = "mini,maxi".Split(',');

            EPStatement stmt = _epService.EPAdministrator.CreateEPL(epl);

            stmt.Events += _listener.Update;

            // Send range query events
            Log.Info("Querying");
            long delta = PerformanceObserver.TimeMillis(
                delegate
            {
                for (int i = 0; i < numLoops; i++)
                {
                    //if (i % 10 == 0) {
                    //    log.Info("At loop #" + i);
                    //}
                    _epService.EPRuntime.SendEvent(assertionCallback.GetEvent(i));
                    EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields,
                                                assertionCallback.GetExpectedValue(i));
                }

                Log.Info("Done Querying");
            });

            Log.Info("delta=" + delta);

            Assert.That(delta, Is.LessThan(1500));
            stmt.Dispose();
        }
コード例 #13
0
        public void TestPerformanceWhereClauseCoercion()
        {
            String stmtText = "select IntPrimitive from MyEvent(TheString='A') as s0 where IntPrimitive in (" +
                              "select LongBoxed from MyEvent(TheString='B').win:length(10000) where s0.IntPrimitive = LongBoxed)";

            EPStatement stmt = _epService.EPAdministrator.CreateEPL(stmtText);

            stmt.Events += _listener.Update;

            // preload with 10k events
            for (int i = 0; i < 10000; i++)
            {
                SupportBean bean = new SupportBean();
                bean.TheString = "B";
                bean.LongBoxed = (long)i;
                _epService.EPRuntime.SendEvent(bean);
            }

            var delta = PerformanceObserver.TimeMillis(
                () =>
            {
                for (int i = 0; i < 10000; i++)
                {
                    int index         = 5000 + i % 1000;
                    SupportBean bean  = new SupportBean();
                    bean.TheString    = "A";
                    bean.IntPrimitive = index;
                    _epService.EPRuntime.SendEvent(bean);
                    Assert.AreEqual(index, _listener.AssertOneGetNewAndReset().Get("IntPrimitive"));
                }
            });

            Assert.That(delta, Is.LessThan(2000));
        }
コード例 #14
0
ファイル: TestPerfPropertyAccess.cs プロジェクト: ikvm/nesper
        public void TestWithPerfPropertyAccess()
        {
            var methodName    = ".testPerfPropertyAccess";
            var joinStatement =
                "select * from " + typeof(SupportBeanCombinedProps).FullName + ".win:length(1)" +
                " where Indexed[0].Mapped('a').value = 'dummy'";

            _epService.EPAdministrator.CreateEPL(joinStatement).Events +=
                _updateListener.Update;

            // Send events for each stream
            var theEvent = SupportBeanCombinedProps.MakeDefaultBean();

            log.Info("{0} : Sending events", methodName);

            var delta = PerformanceObserver.TimeMillis(
                () =>
            {
                for (int i = 0; i < 10000; i++)
                {
                    SendEvent(theEvent);
                }
                log.Info(methodName + " Done sending events");
            });

            log.Info("{0} : delta={1}", methodName, delta);

            Assert.That(delta, Is.LessThan(1000));
        }
コード例 #15
0
        public void TestInKeywordMultiIndex()
        {
            _epServiceRetained.EPAdministrator.Configuration.AddEventType <SupportBean_S0>("S0");

            String stmtText = INDEX_CALLBACK_HOOK + "select * from S0 s0, " +
                              " sql:MyDB ['select mycol1, mycol2, mycol3 from mytesttable_large'] as s1 " +
                              " where p00 in (mycol2, mycol1)";
            EPStatement statement = _epServiceRetained.EPAdministrator.CreateEPL(stmtText);

            _listener         = new SupportUpdateListener();
            statement.Events += _listener.Update;

            QueryPlanIndexDescHistorical historical = SupportQueryPlanIndexHook.AssertHistoricalAndReset();

            Assert.That(historical.IndexName, Is.EqualTo(typeof(PollResultIndexingStrategyIndexSingleArray).Name));
            Assert.That(historical.StrategyName, Is.EqualTo(typeof(HistoricalIndexLookupStrategyInKeywordMulti).Name));

            var delta = PerformanceObserver.TimeMillis(
                () =>
            {
                for (int i = 0; i < 2000; i++)
                {
                    _epServiceRetained.EPRuntime.SendEvent(new SupportBean_S0(i, "815"));
                    Assert.AreEqual(815, _listener.AssertOneGetNewAndReset().Get("s1.mycol3"));
                }
            });

            Log.Info("delta=" + delta);
            Assert.That(delta, Is.LessThan(500));
        }
コード例 #16
0
            public void Run(RegressionEnvironment env)
            {
                SupportUpdateListener listener = new SupportUpdateListener();
                for (int i = 0; i < 100; i++) {
                    string epl = "@Name('s" + i + "') select * from SupportBean(TheString = '" + i + "' or IntPrimitive=" + i + ")";
                    EPCompiled compiled = env.Compile(epl);
                    env.Deploy(compiled).Statement("s" + i).AddListener(listener);
                }

                var delta = PerformanceObserver.TimeMillis(
                    () => {
                        // System.out.println("Starting " + DateTime.print(new Date()));
                        for (int i = 0; i < 10000; i++) {
                            env.SendEventBean(new SupportBean("100", 1));
                            Assert.IsTrue(listener.IsInvoked);
                            listener.Reset();
                        }
                    });
#if DEBUG
                Assert.That(delta, Is.LessThan(1500));
#else
				Assert.That(delta, Is.LessThan(500));
#endif

                env.UndeployAll();
            }
コード例 #17
0
        private void RunAssertionEquals(string epl, SupportUpdateListener[] listeners)
        {
            // test function returns lookup value and "equals"
            for (var i = 0; i < listeners.Length; i++)
            {
                var stmt = _epService.EPAdministrator.CreateEPL(epl.Replace("!NUM!", i.ToString(CultureInfo.InvariantCulture)));
                stmt.AddListener(listeners[i]);
            }

            MyLib.ResetCountInvoked();

            var loops = 1000;
            var delta = PerformanceObserver.TimeMillis(
                () =>
            {
                for (var i = 0; i < loops; i++)
                {
                    _epService.EPRuntime.SendEvent(new SupportBean("E_" + i % listeners.Length, 0));
                    var listener = listeners[i % listeners.Length];
                    Assert.IsTrue(listener.GetAndClearIsInvoked());
                }
            });

            Assert.AreEqual(loops, MyLib.CountInvoked);

            Log.Info("Equals delta=" + delta);
            Assert.That(delta, Is.LessThan(1000), "Delta is " + delta);
            _epService.EPAdministrator.DestroyAllStatements();
        }
コード例 #18
0
        private void TryPerformanceOneCriteria(String stmtText)
        {
            EPStatement stmt = _epService.EPAdministrator.CreateEPL(stmtText);

            stmt.Events += _listener.Update;

            // preload with 10k events
            for (int i = 0; i < 10000; i++)
            {
                _epService.EPRuntime.SendEvent(new SupportBean_S1(i, Convert.ToString(i)));
            }

            var delta = PerformanceObserver.TimeMillis(
                () =>
            {
                for (int i = 0; i < 10000; i++)
                {
                    int index = 5000 + i % 1000;
                    _epService.EPRuntime.SendEvent(new SupportBean_S0(index, Convert.ToString(index)));
                    Assert.AreEqual(index, _listener.AssertOneGetNewAndReset().Get("id"));
                }
            });

            Assert.That(delta, Is.LessThan(1000));
        }
コード例 #19
0
        public void TestMultithreaded()
        {
            const int    numSymbols         = 1;
            const int    numThreads         = 4;
            const int    numEventsPerThread = 50000;
            const double timeWindowSize     = 0.2;

            // Set up threads, statements and listeners
            SetUp(numSymbols, numThreads, numEventsPerThread, timeWindowSize);

            // Start threads
            double delta = PerformanceObserver.TimeMillis(
                delegate
            {
                _threads.ForEach(t => t.Start());
                _threads.ForEach(t => t.Join());
            });

            // Check listener results
            long totalReceived = 0;

            foreach (ResultUpdateListener listener in _listeners)
            {
                totalReceived += listener.NumReceived;
                Assert.IsFalse(listener.IsCaughtRuntimeException);
            }
            double numTimeWindowAdvancements = delta / 1000 / timeWindowSize;

            Log.Info("Completed, expected=" + numEventsPerThread * numThreads +
                     " numTimeWindowAdvancements=" + numTimeWindowAdvancements +
                     " totalReceived=" + totalReceived);
            Assert.IsTrue(totalReceived < numEventsPerThread * numThreads + numTimeWindowAdvancements + 1);
            Assert.IsTrue(totalReceived >= numEventsPerThread * numThreads);
        }
コード例 #20
0
        public void TestPerformance()
        {
            int numEvents  = 1;
            int numThreads = 2;

            Configuration config = new Configuration();

            config.EngineDefaults.Threading.IsListenerDispatchPreserveOrder = false;
            EPServiceProvider engine = EPServiceProviderManager.GetDefaultProvider(config);

            engine.EPAdministrator.Configuration.AddEventType(typeof(TransactionEvent));
            engine.EPAdministrator.Configuration.AddPlugInSingleRowFunction("MyDynModel", GetType().FullName, "MyDynModel");

            String      epl  = "select MyDynModel({Col_001, Col_002, Col_003}) as model_score from TransactionEvent";
            EPStatement stmt = engine.EPAdministrator.CreateEPL(epl);

            stmt.Subscriber = new MySubscriber();

            var queue = new LinkedBlockingQueue <Runnable>();
            var latch = new CountDownLatch(numEvents);

            for (int i = 0; i < numEvents; i++)
            {
                queue.Push((new MyRunnable(engine.EPRuntime, latch, new TransactionEvent(1, 2, 3))).Run);
            }

            var threads = Executors.NewFixedThreadPool(numThreads);

            var delta = PerformanceObserver.TimeMillis(
                () =>
            {
                for (int ii = 0; ii < numThreads; ii++)
                {
                    threads.Submit(
                        () =>
                    {
                        Runnable runnable;
                        while (queue.Pop(0, out runnable))
                        {
                            runnable.Invoke();
                        }
                    });
                }


                //ThreadPoolExecutor threads = new ThreadPoolExecutor(numThreads, numThreads, 10, TimeUnit.SECONDS, queue);
                //threads.PrestartAllCoreThreads();
                latch.Await(TimeSpan.FromMinutes(1));
                if (latch.Count > 0)
                {
                    throw new Exception("Failed to complete in 1 minute");
                }
            });

            Console.WriteLine("Took " + delta + " millis");
            threads.Shutdown();
            threads.AwaitTermination(TimeSpan.FromSeconds(10));
        }
コード例 #21
0
        private void TrySend(EPServiceProvider epService, int numThreads, int numRepeats, int numStatements)
        {
            // Create same statement X times
            var stmt      = new EPStatement[numStatements];
            var listeners = new SupportMTUpdateListener[stmt.Length];

            for (int i = 0; i < stmt.Length; i++)
            {
                stmt[i] = epService.EPAdministrator.CreateEPL(
                    " select * " +
                    " from " + typeof(SupportMarketDataBean).FullName + "#groupwin(symbol)#uni(price)");
                listeners[i]    = new SupportMTUpdateListener();
                stmt[i].Events += listeners[i].Update;
            }

            var threadPool = Executors.NewFixedThreadPool(numThreads);
            var future     = new Future <bool> [numThreads];

            // Start send threads
            // Each threads sends each symbol with price = 0 to numRepeats
            long delta = PerformanceObserver.TimeMillis(
                () => {
                for (int i = 0; i < numThreads; i++)
                {
                    var callable = new StmtSharedViewCallable(numRepeats, epService, SYMBOLS);
                    future[i]    = threadPool.Submit(callable);
                }

                // Shut down
                threadPool.Shutdown();
                threadPool.AwaitTermination(10, TimeUnit.SECONDS);
            });

            for (int i = 0; i < numThreads; i++)
            {
                Assert.IsTrue(future[i].GetValueOrDefault());
            }

            Assert.That(delta, Is.LessThan(5000));   // should take less then 5 seconds even for 100 statements as they need to share resources thread-safely

            // Assert results
            foreach (SupportMTUpdateListener listener in listeners)
            {
                Assert.AreEqual(numRepeats * numThreads * SYMBOLS.Length, listener.NewDataList.Count);
                EventBean[] newDataLast = listener.NewDataList[listener.NewDataList.Count - 1];
                Assert.AreEqual(1, newDataLast.Length);
                var result = newDataLast[0];
                Assert.AreEqual(numRepeats * numThreads, result.Get("datapoints").AsLong());
                Assert.IsTrue(Collections.List(SYMBOLS).Contains(result.Get("symbol")));
                Assert.AreEqual(SumToN(numRepeats) * numThreads, result.Get("total"));
                listener.Reset();
            }

            for (int i = 0; i < stmt.Length; i++)
            {
                stmt[i].Stop();
            }
        }
コード例 #22
0
        private void TryPerformanceDispatch(int numThreads, int numRepeats)
        {
            var listener = new MyListener();

            _engine.EPAdministrator.GetStatement("select").Events += listener.Update;

            var random  = new Random();
            var eventId = 0;
            var events  = new IList <object> [numThreads];

            for (int threadNum = 0; threadNum < numThreads; threadNum++)
            {
                events[threadNum] = new List <Object>();
                for (int eventNum = 0; eventNum < numRepeats; eventNum++)
                {
                    // range: 1 to 1000
                    int partition = random.Next(0, 51);
                    eventId++;
                    events[threadNum].Add(new SupportBean(partition.ToString(CultureInfo.InvariantCulture), eventId));
                }
            }

            var threadPool = Executors.NewFixedThreadPool(numThreads);
            var futures    = new Future <object> [numThreads];

            var delta = PerformanceObserver.TimeMillis(
                () =>
            {
                for (int i = 0; i < numThreads; i++)
                {
                    var callable = new SendEventCallable(i, _engine, events[i].GetEnumerator());
                    futures[i]   = threadPool.Submit(callable);
                }

                threadPool.Shutdown();
                threadPool.AwaitTermination(TimeSpan.FromSeconds(10));

                foreach (var future in futures)
                {
                    Assert.AreEqual(true, future.GetValueOrDefault());
                }
            });

            // print those events not received
            foreach (var eventList in events)
            {
                foreach (var theEvent in eventList.Cast <SupportBean>())
                {
                    if (!listener.Beans.Contains(theEvent))
                    {
                        Log.Info("Expected event was not received, event " + theEvent);
                    }
                }
            }

            Assert.That(listener.Beans.Count, Is.EqualTo(numRepeats * numThreads));
            Assert.That(delta, Is.LessThan(500), "delta=" + delta);
        }
コード例 #23
0
        private void RunAssertionPerformance(bool namedWindow, EventRepresentationChoice outputType)
        {
            string eplCreate = namedWindow ?
                               outputType.GetAnnotationText() + " create window MyWindow#keepall as (c1 string, c2 int)" :
                               "create table MyWindow(c1 string primary key, c2 int)";
            EPStatement stmtNamedWindow = _epService.EPAdministrator.CreateEPL(eplCreate);

            Assert.IsTrue(outputType.MatchesClass(stmtNamedWindow.EventType.UnderlyingType));

            // preload events
            EPStatement stmt         = _epService.EPAdministrator.CreateEPL("insert into MyWindow select TheString as c1, IntPrimitive as c2 from SupportBean");
            int         totalUpdated = 5000;

            for (int i = 0; i < totalUpdated; i++)
            {
                _epService.EPRuntime.SendEvent(new SupportBean("E" + i, 0));
            }
            stmt.Dispose();

            string epl = "on SupportBean sb merge MyWindow nw where nw.c1 = sb.TheString " +
                         "when matched then update set nw.c2=sb.IntPrimitive";

            stmt = _epService.EPAdministrator.CreateEPL(epl);
            stmt.AddListener(_mergeListener);

            // prime
            for (int i = 0; i < 100; i++)
            {
                _epService.EPRuntime.SendEvent(new SupportBean("E" + i, 1));
            }
            var delta = PerformanceObserver.TimeMillis(
                () =>
            {
                for (int i = 0; i < totalUpdated; i++)
                {
                    _epService.EPRuntime.SendEvent(new SupportBean("E" + i, 1));
                }
            });

            // verify
            IEnumerator <EventBean> events = stmtNamedWindow.GetEnumerator();
            int count = 0;

            while (events.MoveNext())
            {
                EventBean next = events.Current;
                Assert.AreEqual(1, next.Get("c2"));
                count++;
            }
            Assert.AreEqual(totalUpdated, count);
            Assert.IsTrue(delta < 500, "Delta=" + delta);

            _epService.EPAdministrator.DestroyAllStatements();
            _epService.EPAdministrator.Configuration.RemoveEventType("MyWindow", true);
        }
コード例 #24
0
        public void TestConstantPerformance()
        {
            _epService.EPAdministrator.Configuration.AddEventType <SupportBean>();
            _epService.EPAdministrator.Configuration.AddEventType(typeof(SupportBean_S0));
            _epService.EPAdministrator.CreateEPL("create window MyWindow.win:keepall() as SupportBean");
            _epService.EPAdministrator.CreateEPL("insert into MyWindow select * from SupportBean");
            _epService.EPAdministrator.CreateEPL("create const variable String MYCONST = 'E331'");

            for (int i = 0; i < 10000; i++)
            {
                _epService.EPRuntime.SendEvent(new SupportBean("E" + i, i * -1));
            }

            // test join
            EPStatement stmtJoin = _epService.EPAdministrator.CreateEPL("select * from SupportBean_S0 s0 unidirectional, MyWindow sb where TheString = MYCONST");

            stmtJoin.Events += _listener.Update;

            var delta = PerformanceObserver.TimeMillis(
                () =>
            {
                for (int i = 0; i < 10000; i++)
                {
                    _epService.EPRuntime.SendEvent(new SupportBean_S0(i, "E" + i));
                    EPAssertionUtil.AssertProps(
                        _listener.AssertOneGetNewAndReset(), "sb.TheString,sb.IntPrimitive".Split(','), new Object[]
                    {
                        "E331",
                        -331
                    });
                }
            });

            Assert.That(delta, Is.LessThan(500), "delta=" + delta);
            stmtJoin.Dispose();

            // test subquery
            EPStatement stmtSubquery = _epService.EPAdministrator.CreateEPL("select * from SupportBean_S0 where exists (select * from MyWindow where TheString = MYCONST)");

            stmtSubquery.Events += _listener.Update;

            delta = PerformanceObserver.TimeMillis(
                () =>
            {
                for (int i = 0; i < 10000; i++)
                {
                    _epService.EPRuntime.SendEvent(new SupportBean_S0(i, "E" + i));
                    Assert.IsTrue(_listener.GetAndClearIsInvoked());
                }
            });

            Assert.That(delta, Is.LessThan(500), "delta=" + delta);
        }
コード例 #25
0
        public void TestOp()
        {
            Configuration config = SupportConfigFactory.GetConfiguration();

            config.EngineDefaults.ThreadingConfig.IsInternalTimerEnabled        = false;
            config.EngineDefaults.ExpressionConfig.IsUdfCache                   = false;
            config.EngineDefaults.ThreadingConfig.IsThreadPoolTimerExec         = true;
            config.EngineDefaults.ThreadingConfig.ThreadPoolTimerExecNumThreads = 5;
            config.AddEventType("MyMap", new Dictionary <String, Object>());
            config.AddImport(typeof(SupportStaticMethodLib).FullName);

            EPServiceProvider epService = EPServiceProviderManager.GetDefaultProvider(config);

            epService.Initialize();
            SendTimer(0, epService);

            Log.Debug("Creating statements");
            int countStatements = 100;
            SupportListenerTimerHRes listener = new SupportListenerTimerHRes();

            for (int i = 0; i < countStatements; i++)
            {
                EPStatement stmt = epService.EPAdministrator.CreateEPL("select SupportStaticMethodLib.Sleep(10) from pattern[every MyMap -> timer:interval(1)]");
                stmt.Events += listener.Update;
            }

            Log.Info("Sending trigger event");
            epService.EPRuntime.SendEvent(new Dictionary <String, Object>(), "MyMap");

            long delta = PerformanceObserver.TimeMillis(() => SendTimer(1000, epService));

            Assert.LessOrEqual(delta, 100, "Delta is " + delta);

            // wait for delivery
            while (true)
            {
                int countDelivered = listener.NewEvents.Count;
                if (countDelivered == countStatements)
                {
                    break;
                }

                Log.Info("Delivered " + countDelivered + ", waiting for more");
                Thread.Sleep(200);
            }

            Assert.AreEqual(100, listener.NewEvents.Count);
            // analyze result
            //List<Pair<Long, EventBean[]>> events = listener.NewEvents;
            //OccuranceResult result = OccuranceAnalyzer.Analyze(events, new long[] {100 * 1000 * 1000L, 10*1000 * 1000L});
            //Log.Info(result);
        }
コード例 #26
0
        public void TestPerfKeyAndRangeOuterJoin()
        {
            _epService.EPAdministrator.Configuration.AddEventType("SupportBean", typeof(SupportBean));
            _epService.EPAdministrator.Configuration.AddEventType("SupportBeanRange", typeof(SupportBeanRange));

            _epService.EPAdministrator.CreateEPL("create window SBR.win:keepall() as SupportBeanRange");
            _epService.EPAdministrator.CreateEPL("@Name('I1') insert into SBR select * from SupportBeanRange");
            _epService.EPAdministrator.CreateEPL("create window SB.win:keepall() as SupportBean");
            _epService.EPAdministrator.CreateEPL("@Name('I2') insert into SB select * from SupportBean");

            // Preload
            Log.Info("Preloading events");
            for (int i = 0; i < 10000; i++)
            {
                _epService.EPRuntime.SendEvent(new SupportBean("G", i));
                _epService.EPRuntime.SendEvent(new SupportBeanRange("R", "G", i - 1, i + 2));
            }
            Log.Info("Done preloading");

            // create
            String epl = "select * " +
                         "from SB sb " +
                         "full outer join " +
                         "SBR sbr " +
                         "on TheString = key " +
                         "where IntPrimitive between rangeStart and rangeEnd";
            EPStatement stmt = _epService.EPAdministrator.CreateEPL(epl);

            stmt.Events += _listener.Update;

            // Repeat
            Log.Info("Querying");
            long delta = PerformanceObserver.TimeMillis(
                delegate
            {
                for (int i = 0; i < 1000; i++)
                {
                    _epService.EPRuntime.SendEvent(new SupportBean("G", 9990));
                    Assert.AreEqual(4, _listener.GetAndResetLastNewData().Length);

                    _epService.EPRuntime.SendEvent(new SupportBeanRange("R", "G", 4, 10));
                    Assert.AreEqual(7, _listener.GetAndResetLastNewData().Length);
                }
                Log.Info("Done Querying");
            });

            Log.Info("delta=" + delta);

            Assert.That(delta, Is.LessThan(500));
            stmt.Dispose();
        }
コード例 #27
0
        public override void Run(EPServiceProvider epService)
        {
            epService.EPAdministrator.Configuration.AddEventType <SupportBean>();
            epService.EPAdministrator.Configuration.AddEventType <SupportBean_S0>();
            epService.EPAdministrator.CreateEPL("create window MyWindow#keepall as SupportBean");
            epService.EPAdministrator.CreateEPL("insert into MyWindow select * from SupportBean");
            epService.EPAdministrator.CreateEPL("create const variable string MYCONST = 'E331'");

            for (int i = 0; i < 10000; i++)
            {
                epService.EPRuntime.SendEvent(new SupportBean("E" + i, i * -1));
            }

            // test join
            EPStatement stmt     = epService.EPAdministrator.CreateEPL("select * from SupportBean_S0 s0 unidirectional, MyWindow sb where TheString = MYCONST");
            var         listener = new SupportUpdateListener();

            stmt.Events += listener.Update;

            long delta = PerformanceObserver.TimeMillis(
                () =>
            {
                ;
                for (int i = 0; i < 10000; i++)
                {
                    epService.EPRuntime.SendEvent(new SupportBean_S0(i, "E" + i));
                    EPAssertionUtil.AssertProps(
                        listener.AssertOneGetNewAndReset(), "sb.TheString,sb.IntPrimitive".Split(','),
                        new object[] { "E331", -331 });
                }
            });

            Assert.IsTrue(delta < 500, "delta=" + delta);
            stmt.Dispose();

            // test subquery
            EPStatement stmtSubquery = epService.EPAdministrator.CreateEPL("select * from SupportBean_S0 where exists (select * from MyWindow where TheString = MYCONST)");

            stmtSubquery.Events += listener.Update;

            delta = PerformanceObserver.TimeMillis(
                () =>
            {
                for (int i = 0; i < 10000; i++)
                {
                    epService.EPRuntime.SendEvent(new SupportBean_S0(i, "E" + i));
                    Assert.IsTrue(listener.GetAndClearIsInvoked());
                }
            });
            Assert.IsTrue(delta < 500, "delta=" + delta);
        }
コード例 #28
0
        private void RunKeyAndRangeAssertion(bool indexShare, bool buildIndex)
        {
            string createEpl = "create window MyWindow.win:keepall() as select * from SupportBean";

            if (indexShare)
            {
                createEpl = "@Hint('enable_window_subquery_indexshare') " + createEpl;
            }

            _epService.EPAdministrator.CreateEPL(createEpl);

            if (buildIndex)
            {
                _epService.EPAdministrator.CreateEPL("create index idx1 on MyWindow(TheString hash, IntPrimitive btree)");
            }

            _epService.EPAdministrator.CreateEPL("insert into MyWindow select * from SupportBean");

            // preload
            for (int i = 0; i < 10000; i++)
            {
                _epService.EPRuntime.SendEvent(new SupportBean(i < 5000 ? "A" : "B", i));
            }

            string[] fields   = "cols.mini,cols.maxi".Split(',');
            string   queryEpl =
                "select (select min(IntPrimitive) as mini, max(IntPrimitive) as maxi from MyWindow " +
                "where TheString = sbr.key and IntPrimitive between sbr.rangeStart and sbr.rangeEnd) as cols from SupportBeanRange sbr";

            EPStatement stmt = _epService.EPAdministrator.CreateEPL(queryEpl);

            stmt.Events += _listener.Update;

            long delta = PerformanceObserver.TimeMillis(
                delegate
            {
                for (int i = 0; i < 1000; i++)
                {
                    _epService.EPRuntime.SendEvent(new SupportBeanRange("R1", "A", 300, 312));
                    EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new Object[] { 300, 312 });
                }
            });

            Assert.IsTrue(delta < 500, "delta=" + delta);
            Log.Info("delta=" + delta);

            _epService.EPAdministrator.DestroyAllStatements();
        }
コード例 #29
0
        private void RunFAFAssertion(string epl, int?expected)
        {
            const int loops = 500;

            var delta = PerformanceObserver.TimeMillis(
                () =>
            {
                var query = _epService.EPRuntime.PrepareQuery(epl);
                for (var i = 0; i < loops; i++)
                {
                    RunFAFQuery(query, expected);
                }
            });

            Assert.That(delta, Is.LessThan(1000));
        }
コード例 #30
0
        public static void SendAssertSpatialAABB(EPServiceProvider epService, SupportUpdateListener listener, int numX, int numY, long deltaMSec)
        {
            var delta = PerformanceObserver.TimeMillis(
                () => {
                for (var x = 0; x < numX; x++)
                {
                    for (var y = 0; y < numY; y++)
                    {
                        epService.EPRuntime.SendEvent(new SupportSpatialAABB("", x, y, 0.1, 0.1));
                        listener.AssertOneGetNewAndReset();
                    }
                }
            });

            Assert.That(delta, Is.LessThan(deltaMSec));
        }