├── performance
├── esper
│ ├── src
│ │ └── main
│ │ │ └── java
│ │ │ └── com
│ │ │ └── softleader
│ │ │ └── esper
│ │ │ └── performance
│ │ │ ├── SimpleFilterSingleQueryPerformanceEsper.java
│ │ │ └── SimpleFilterMultipleQueryPerformanceEsper.java
│ ├── pom.xml
│ └── esperpom.xml
├── wso2
│ ├── src
│ │ └── main
│ │ │ ├── resources
│ │ │ └── log4j.properties
│ │ │ └── java
│ │ │ └── com
│ │ │ └── softleader
│ │ │ └── siddhi
│ │ │ └── performance
│ │ │ ├── PartitionPerformance.java
│ │ │ ├── SimpleFilterSingleQueryPerformance.java
│ │ │ ├── SimpleFilterSingleQueryWithDisruptorPerformance.java
│ │ │ ├── SimpleFilterMultipleQueryPerformance.java
│ │ │ └── SimpleFilterMultipleQueryWithDisruptorPerformance.java
│ ├── pom.xml
│ └── siddhipom.xml
└── data
│ └── cep_performance.csv
└── README.md
/performance/esper/src/main/java/com/softleader/esper/performance/SimpleFilterSingleQueryPerformanceEsper.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhenghorse/CEP/HEAD/performance/esper/src/main/java/com/softleader/esper/performance/SimpleFilterSingleQueryPerformanceEsper.java
--------------------------------------------------------------------------------
/performance/wso2/src/main/resources/log4j.properties:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License");
5 | # you may not use this file except in compliance with the License.
6 | # You may obtain a copy of the License at
7 | #
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 | #
16 |
17 |
18 | # For the general syntax of property based configuration files see the
19 | # documenation of org.apache.log4j.PropertyConfigurator.
20 |
21 | # The root category uses the appender called A1. Since no priority is
22 | # specified, the root category assumes the default priority for root
23 | # which is DEBUG in log4j. The root category is the only category that
24 | # has a default priority. All other categories need not be assigned a
25 | # priority in which case they inherit their priority from the
26 | # hierarchy.
27 |
28 | #log4j.rootLogger=DEBUG, stdout
29 | log4j.rootLogger=INFO, stdout
30 |
31 | log4j.appender.stdout=org.apache.log4j.ConsoleAppender
32 | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
33 | log4j.appender.stdout.layout.ConversionPattern=%m%n
34 | #log4j.appender.stdout.layout.ConversionPattern=[%t] %-5p %c %x - %m%n
35 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # CEP学习
2 | __________________
3 | ### Esper学习
4 | - [官网资料](http://www.espertech.com/esper/)
5 | - [csdn luonanqin对Esper的专栏介绍](http://blog.csdn.net/luonanqin/article/details/21300263)
6 |
7 | ### WSO2 CEP学习
8 | - [WSO2 CEP](http://wso2.com/products/complex-event-processor)
9 |
10 | ### Drools
11 | - [Drools官网](http://drools.org/)
12 | - [docker drools-workbench-showcase](https://registry.hub.docker.com/u/jboss/drools-workbench-showcase/)
13 |
14 | ### Pulsar
15 | - [Pulsar官网--eBay CEP](http://gopulsar.io/)
16 | - [Pulsar github地址](https://github.com/pulsarIO/realtime-analytics)
17 |
18 | ### 市面上CEP产品大全
19 | - [CEP Tooling Market Survey 2014](http://www.complexevents.com/2014/12/03/cep-tooling-market-survey-2014/)
20 |
21 | ### CEP比较
22 | - [WSO2 CEP(Siddhi与Esper对比信息)](http://srinathsview.blogspot.com/2011/12/siddhi-second-look-at-complex-event.html)
23 | - [WSO2 CEP与Esper对比信息](http://wso2.com/library/blog-post/2013/08/cep-performance-processing-100k-to-millions-of-events-per-second-using-wso2-complex-event/)
24 | - [CEP Tooling Market Survey 2014(CEP工具情况)](http://www.complexevents.com/2014/12/03/cep-tooling-market-survey-2014/)
25 |
26 | ### Stream与CEP结合
27 | - [Spark Streaming与Siddhi结合处理流式数据](https://github.com/Stratio/streaming-cep-engine)
28 | - [Storm与Esper结合](https://github.com/tomdz/storm-esper)
29 |
30 | ### Esper的不足
31 | - 没有事件定义设计器
32 |
33 | ### Esper与WSO2CEP性能比较
34 | - window10 X64 测试平台配置:I5-5200U CPU/12G MM/256G SSD
35 | - ubuntu12.04 LTS X64 测试平台配置:I5-4590 CPU/4G MM/500G 机械硬盘
36 | - Esper吞吐量大概在200W/sec左右
37 | - WSO2CEP吞吐量大概在600W/sec左右,但在windows平台中测试出来只有15W/sec,同样的代码,不知为何数据会差这么多
38 |
--------------------------------------------------------------------------------
/performance/data/cep_performance.csv:
--------------------------------------------------------------------------------
1 | esper,siddhi
2 | 993541.9771,2298850.575
3 | 2053388.09,6472498.382
4 | 2103049.422,6410253.205
5 | 2107481.56,7042250
6 | 2089864.159,7117437.722
7 | 2081165.453,7092202.128
8 | 2089864.159,7142864.286
9 | 2066115.702,7117427.046
10 | 2083333.333,6920415.225
11 | 2006018.054,7067137.809
12 | 1978239.367,7067144.876
13 | 2063983.488,6993000
14 | 2018163.471,7042253.521
15 | 2049180.328,6920418.685
16 | 2083333.333,6920446.367
17 | 2068252.327,6968606.272
18 | 2076843.198,6688963.211
19 | 2085505.735,6993010.49
20 | 2051282.051,7092202.128
21 | 2042900.919,6968637.631
22 | 2055498.458,6756756.757
23 | 2081165.453,6825941.98
24 | 2085505.735,6896548.276
25 | 2094240.838,6688959.866
26 | 2085505.735,6802721.088
27 | 2081165.453,6756760.135
28 | 2076843.198,6557373.77
29 | 2083333.333,6849318.493
30 | 2068252.327,6993006.993
31 | 2087682.672,6872859.107
32 | 2081165.453,6644508.306
33 | 2076843.198,6849315.068
34 | 2079002.079,7067137.809
35 | 2083333.333,6872855.67
36 | 2079002.079,6993006.993
37 | 2085505.735,7067141.343
38 | 2096436.059,6968651.568
39 | 2087682.672,6920397.924
40 | 2083333.333,6896555.172
41 | 2089864.159,6993003.497
42 | 2070393.375,6779661.017
43 | 2085505.735,6779664.407
44 | 2074688.797,6872869.416
45 | 2076843.198,6920394.464
46 | 2085505.735,7017561.404
47 | 2076843.198,6825924.915
48 | 2092050.209,6920411.765
49 | 2076843.198,6896551.724
50 | 2085505.735,6944451.389
51 | 2087682.672,6920411.765
52 | 2083333.333,6849315.068
53 | 2085505.735,6920415.225
54 | 2083333.333,6849311.644
55 | 2092050.209,6600663.366
56 | 2081165.453,7042278.169
57 | 2079002.079,6849287.671
58 | 2094240.838,6968644.599
59 | 2092050.209,6944444.444
60 | 2087682.672,7067148.41
61 | 2076843.198,6896562.069
62 | 2083333.333,6666650
63 | 2072538.86,6872845.361
64 | 2081165.453,6514661.238
65 | 2085505.735,6756753.378
66 | 2089864.159,6944447.917
67 | 2083333.333,6944444.444
68 | 2098635.887,6872848.797
69 | 2096436.059,7017547.368
70 | 2085505.735,6734016.835
71 | 2085505.735,6872841.924
72 | 2092050.209,6802717.687
73 | 2092050.209,6920415.225
74 | 2098635.887,6944447.917
75 | 2074688.797,6802721.088
76 | 2042900.919,7042253.521
77 | 1988071.571,6756753.378
78 |
--------------------------------------------------------------------------------
/performance/esper/pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 |
4 | com.espertech
5 | esper_examples
6 | 5.2.0
7 | esperpom.xml
8 |
9 | Esper Examples - Benchmark
10 | com.espertech
11 | cep-esper-performance
12 | jar
13 | Esper Example Benchmark
14 |
15 |
16 | com.espertech
17 | esper
18 |
19 |
20 | log4j
21 | log4j
22 |
23 |
24 | commons-logging
25 | commons-logging
26 |
27 |
28 | junit
29 | junit
30 |
31 |
32 |
33 |
34 |
35 | org.apache.maven.plugins
36 | maven-jar-plugin
37 |
38 |
39 |
40 | EsperTech
41 |
42 |
43 |
44 |
45 |
46 | org.apache.maven.plugins
47 | maven-compiler-plugin
48 |
49 | 1.6
50 | 1.6
51 |
52 |
53 |
54 | org.apache.maven.plugins
55 | maven-surefire-plugin
56 |
57 | -Dlog4j.configuration=../etc/log4j.xml
58 | -Xms256m -Xmx256m
59 |
60 |
61 | log4j.configuration
62 | log4j.xml
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 | etc
71 |
72 |
73 |
74 |
75 |
--------------------------------------------------------------------------------
/performance/wso2/src/main/java/com/softleader/siddhi/performance/PartitionPerformance.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.softleader.siddhi.performance;
18 |
19 | import org.wso2.siddhi.core.ExecutionPlanRuntime;
20 | import org.wso2.siddhi.core.SiddhiManager;
21 | import org.wso2.siddhi.core.event.Event;
22 | import org.wso2.siddhi.core.stream.input.InputHandler;
23 | import org.wso2.siddhi.core.stream.output.StreamCallback;
24 |
25 | public class PartitionPerformance {
26 | private static int count = 0;
27 |
28 | public static void main(String[] args) throws InterruptedException {
29 | SiddhiManager siddhiManager = new SiddhiManager();
30 |
31 | String executionPlan = "" +
32 | "define stream cseEventStream (symbol string, price float, volume long);" +
33 | "" +
34 | "partition with (symbol of cseEventStream) " +
35 | "begin " +
36 | " @info(name = 'query1') " +
37 | " from cseEventStream[price > 70] " +
38 | " select * " +
39 | " insert into outputStream ;" +
40 | "end;";
41 |
42 | ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(executionPlan);
43 | executionPlanRuntime.addCallback("outputStream", new StreamCallback() {
44 |
45 | @Override
46 | public void receive(Event[] events) {
47 | // EventPrinter.print(events);
48 | }
49 | });
50 |
51 |
52 | InputHandler inputHandler = executionPlanRuntime.getInputHandler("cseEventStream");
53 | executionPlanRuntime.start();
54 |
55 | while (true) {
56 | count++;
57 | inputHandler.send(new Object[]{"WSO2" + count, 55.6f, 100});
58 | System.out.println("Partition created :" + count);
59 | }
60 |
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/performance/wso2/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 |
20 | org.wso2.siddhi
21 | siddhi
22 | 3.0.0-SNAPSHOT
23 | siddhipom.xml
24 |
25 | 4.0.0
26 | cep-siddhi-performance
27 | Siddhi Performance Samples
28 |
29 |
30 |
31 |
32 |
33 | org.wso2.siddhi
34 | siddhi-query-api
35 | compile
36 |
37 |
38 | org.wso2.siddhi
39 | siddhi-query-compiler
40 | compile
41 |
42 |
43 | org.wso2.siddhi
44 | siddhi-core
45 | compile
46 |
47 |
48 | org.apache.log4j.wso2
49 | log4j
50 | compile
51 |
52 |
53 | org.antlr
54 | antlr4-runtime
55 | compile
56 |
57 |
58 | org.wso2.lmax
59 | disruptor
60 | compile
61 |
62 |
63 |
64 |
65 |
--------------------------------------------------------------------------------
/performance/esper/esperpom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 | Esper Examples
4 | com.espertech
5 | esper_examples
6 | 5.2.0
7 | pom
8 | Esper CEP ESP engine for Java examples
9 |
10 |
11 | central
12 | Maven Repository Switchboard
13 | default
14 | http://repo1.maven.org/maven2
15 |
16 | false
17 |
18 |
19 |
20 |
21 | maven2-repository.dev.java.net
22 | Java.net Repository for Maven
23 | https://maven-repository.dev.java.net/nonav/repository
24 | legacy
25 |
26 |
27 |
28 | autoid
29 | benchmark
30 | cycledetect
31 | marketdatafeed
32 | matchmaker
33 | namedwinquery
34 | ohlcpluginview
35 | qos_sla
36 | rfidassetzone
37 | runtimeconfig
38 | servershell
39 | stockticker
40 | terminalsvc
41 | terminalsvc-jse
42 | transaction
43 | trivia
44 |
45 |
46 |
47 |
48 | com.espertech
49 | esper
50 | 5.2.0
51 |
52 |
53 | log4j
54 | log4j
55 | 1.2.17
56 |
57 |
58 | javax.jms
59 | jms
60 |
61 |
62 | com.sun.jdmk
63 | jmxtools
64 |
65 |
66 | com.sun.jmx
67 | jmxri
68 |
69 |
70 |
71 |
72 | commons-logging
73 | commons-logging
74 | 1.1.3
75 |
76 |
77 | junit
78 | junit
79 | 4.11
80 | test
81 |
82 |
83 |
84 | javaee
85 | javaee-api
86 | 5
87 |
88 |
89 |
90 |
91 |
--------------------------------------------------------------------------------
/performance/wso2/src/main/java/com/softleader/siddhi/performance/SimpleFilterSingleQueryPerformance.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.softleader.siddhi.performance;
17 |
18 | import org.wso2.siddhi.core.ExecutionPlanRuntime;
19 | import org.wso2.siddhi.core.SiddhiManager;
20 | import org.wso2.siddhi.core.event.Event;
21 | import org.wso2.siddhi.core.stream.input.InputHandler;
22 | import org.wso2.siddhi.core.stream.output.StreamCallback;
23 |
24 | public class SimpleFilterSingleQueryPerformance {
25 | private static int count = 0;
26 | private static volatile long start = System.currentTimeMillis();
27 |
28 | public static void main(String[] args) throws InterruptedException {
29 | SiddhiManager siddhiManager = new SiddhiManager();
30 |
31 | String executionPlan = ""
32 | + "@plan:parallel "
33 | + "define stream cseEventStream (symbol string, price float, volume long);"
34 | + "" + "@info(name = 'query1') "
35 | + "from cseEventStream[price > 70] " + "select * "
36 | + "insert into outputStream ;";
37 |
38 | ExecutionPlanRuntime executionPlanRuntime = siddhiManager
39 | .createExecutionPlanRuntime(executionPlan);
40 | executionPlanRuntime.addCallback("outputStream", new StreamCallback() {
41 | private long chunk = 0;
42 | private long prevCount = 0;
43 |
44 | @Override
45 | public void receive(Event[] events) {
46 | // Event event = events[0];
47 | // Object[] data = event.getData();
48 | // System.out.println(count+":symbol:"+data[0]+",price:"+data[1]+",volume:"+data[2]);
49 | count += events.length;
50 | long currentChunk = count / 2000000;
51 | if (currentChunk != chunk) {
52 | long end = System.currentTimeMillis();
53 | double tp = ((count - prevCount) * 1000.0 / (end - start));
54 | // System.out.println("Throughput = " + tp + " Event/sec");
55 | System.out.println(tp);
56 | start = end;
57 | chunk = currentChunk;
58 | prevCount = count;
59 | }
60 | }
61 | });
62 |
63 | InputHandler inputHandler = executionPlanRuntime
64 | .getInputHandler("cseEventStream");
65 | executionPlanRuntime.start();
66 | int num = 1;
67 | while (true) {
68 | inputHandler.send(new Object[] { "WSO2", 50.6f, 100 });
69 | inputHandler.send(new Object[] { "IBM", 70.6f, 100 });
70 | inputHandler.send(new Object[] { "WSO2", 51.6f, 100 });
71 | inputHandler.send(new Object[] { "IBM", 71.6f, 100 });
72 | inputHandler.send(new Object[] { "WSO2", 52.6f, 100 });
73 | inputHandler.send(new Object[] { "IBM", 72.6f, 100 });
74 | inputHandler.send(new Object[] { "WSO2", 53.6f, 100 });
75 | inputHandler.send(new Object[] { "IBM", 73.6f, 100 });
76 | inputHandler.send(new Object[] { "WSO2", 54.6f, 100 });
77 | inputHandler.send(new Object[] { "IBM", 74.6f, 100 });
78 | // num++;
79 | // if (num > 2000) {
80 | // break;
81 | // }
82 | }
83 |
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/performance/esper/src/main/java/com/softleader/esper/performance/SimpleFilterMultipleQueryPerformanceEsper.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.softleader.esper.performance;
17 |
18 | import com.espertech.esper.client.EPAdministrator;
19 | import com.espertech.esper.client.EPRuntime;
20 | import com.espertech.esper.client.EPServiceProvider;
21 | import com.espertech.esper.client.EPServiceProviderManager;
22 | import com.espertech.esper.client.EPStatement;
23 | import com.espertech.esper.client.EventBean;
24 | import com.espertech.esper.client.UpdateListener;
25 |
26 | public class SimpleFilterMultipleQueryPerformanceEsper {
27 | private static int count = 0;
28 | private static volatile long start = System.currentTimeMillis();
29 |
30 | public static void main(String[] args) throws InterruptedException {
31 | EPServiceProvider epService = EPServiceProviderManager
32 | .getDefaultProvider();
33 | EPAdministrator admin = epService.getEPAdministrator();
34 | EPRuntime runtime = epService.getEPRuntime();
35 |
36 | admin.createEPL("create objectarray schema cseEventStream (symbol string, price float, volume long)");
37 | admin.createEPL("create objectarray schema cseEventStream2(symbol string, price float, volume long)");
38 | String epl = "select symbol, price, volume from cseEventStream(price < 70);"
39 | +"select symbol, price, volume from cseEventStream(volume > 90);";
40 |
41 | EPStatement state = admin.createEPL(epl);
42 | state.addListener(new UpdateListener() {
43 | private long chunk = 0;
44 | private long prevCount = 0;
45 |
46 | @Override
47 | public void update(EventBean[] newEvents, EventBean[] oldEvents) {
48 | count += newEvents.length;
49 | long currentChunk = count / 2000000;
50 | if (currentChunk != chunk) {
51 | long end = System.currentTimeMillis();
52 | double tp = ((count - prevCount) * 1000.0 / (end - start));
53 | System.out.println("Throughput = " + tp + " Event/sec");
54 | start = end;
55 | chunk = currentChunk;
56 | prevCount = count;
57 | }
58 | }
59 |
60 | });
61 |
62 | int num = 1;
63 | while (true) {
64 | runtime.sendEvent(new Object[]{"WSO2", 55.6f, 100});
65 | runtime.sendEvent(new Object[]{"IBM", 75.6f, 100});
66 | runtime.sendEvent(new Object[]{"WSO2", 100f, 80});
67 | runtime.sendEvent(new Object[]{"IBM", 75.6f, 100});
68 | runtime.sendEvent(new Object[]{"WSO2", 55.6f, 100});
69 | runtime.sendEvent(new Object[]{"IBM", 75.6f, 100});
70 | runtime.sendEvent(new Object[]{"WSO2", 100f, 80});
71 | runtime.sendEvent(new Object[]{"IBM", 75.6f, 100});
72 | num ++;
73 | if (num > 100) {
74 | break;
75 | }
76 | }
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/performance/wso2/src/main/java/com/softleader/siddhi/performance/SimpleFilterSingleQueryWithDisruptorPerformance.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.softleader.siddhi.performance;
17 |
18 | import org.wso2.siddhi.core.ExecutionPlanRuntime;
19 | import org.wso2.siddhi.core.SiddhiManager;
20 | import org.wso2.siddhi.core.event.Event;
21 | import org.wso2.siddhi.core.stream.input.InputHandler;
22 | import org.wso2.siddhi.core.stream.output.StreamCallback;
23 |
24 | public class SimpleFilterSingleQueryWithDisruptorPerformance {
25 | private static int count = 0;
26 | private static volatile long start = System.currentTimeMillis();
27 |
28 | public static void main(String[] args) throws InterruptedException {
29 | SiddhiManager siddhiManager = new SiddhiManager();
30 |
31 | String executionPlan = "" +
32 | "@plan:parallel " +
33 | "" +
34 | "define stream cseEventStream (symbol string, price float, volume long);" +
35 | "" +
36 | "@info(name = 'query1') " +
37 | "from cseEventStream[price > 70] " +
38 | "select symbol,price,volume " +
39 | "insert into outputStream ;";
40 |
41 | ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(executionPlan);
42 |
43 | executionPlanRuntime.addCallback("outputStream", new StreamCallback() {
44 | private long chunk = 0;
45 | private long prevCount = 0;
46 |
47 | @Override
48 | public void receive(Event[] inEvents) {
49 | count += inEvents.length;
50 | long currentChunk = count / 2000000;
51 | if (currentChunk != chunk) {
52 | long end = System.currentTimeMillis();
53 | double tp = ((count - prevCount) * 1000.0 / (end - start));
54 | // System.out.println("Throughput = " + tp + " Event/sec");
55 | System.out.println(tp);
56 | start = end;
57 | chunk = currentChunk;
58 | prevCount = count;
59 | }
60 | }
61 |
62 | });
63 |
64 | InputHandler inputHandler = executionPlanRuntime.getInputHandler("cseEventStream");
65 | executionPlanRuntime.start();
66 | while (true) {
67 | inputHandler.send(new Object[]{"WSO2", 55.6f, 100});
68 | inputHandler.send(new Object[]{"IBM", 75.6f, 100});
69 | inputHandler.send(new Object[]{"WSO2", 55.6f, 100});
70 | inputHandler.send(new Object[]{"IBM", 75.6f, 100});
71 | inputHandler.send(new Object[]{"WSO2", 55.6f, 100});
72 | inputHandler.send(new Object[]{"IBM", 75.6f, 100});
73 | inputHandler.send(new Object[]{"WSO2", 55.6f, 100});
74 | inputHandler.send(new Object[]{"IBM", 75.6f, 100});
75 | }
76 | // executionPlanRuntime.shutdown();
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/performance/wso2/src/main/java/com/softleader/siddhi/performance/SimpleFilterMultipleQueryPerformance.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.softleader.siddhi.performance;
17 |
18 | import org.wso2.siddhi.core.ExecutionPlanRuntime;
19 | import org.wso2.siddhi.core.SiddhiManager;
20 | import org.wso2.siddhi.core.event.Event;
21 | import org.wso2.siddhi.core.stream.input.InputHandler;
22 | import org.wso2.siddhi.core.stream.output.StreamCallback;
23 |
24 | public class SimpleFilterMultipleQueryPerformance {
25 | private static int count = 0;
26 | private static volatile long start = System.currentTimeMillis();
27 |
28 | public static void main(String[] args) throws InterruptedException {
29 | SiddhiManager siddhiManager = new SiddhiManager();
30 |
31 | String executionPlan = "" +
32 | "define stream cseEventStream (symbol string, price float, volume int);" +
33 | "define stream cseEventStream2 (symbol string, price float, volume int);" +
34 | "" +
35 | "@info(name = 'query1') " +
36 | "from cseEventStream[70 > price] " +
37 | "select * " +
38 | "insert into outputStream ;" +
39 | "" +
40 | "@info(name = 'query2') " +
41 | "from cseEventStream[volume > 90] " +
42 | "select * " +
43 | "insert into outputStream ;";
44 |
45 | ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(executionPlan);
46 |
47 | executionPlanRuntime.addCallback("outputStream", new StreamCallback() {
48 | private long chunk = 0;
49 | private long prevCount = 0;
50 |
51 | @Override
52 | public void receive(Event[] events) {
53 | count += events.length;
54 | long currentChunk = count / 2000000;
55 | if (currentChunk != chunk) {
56 | long end = System.currentTimeMillis();
57 | double tp = ((count - prevCount) * 1000.0 / (end - start));
58 | System.out.println("Throughput = " + tp + " Event/sec");
59 | start = end;
60 | chunk = currentChunk;
61 | prevCount = count;
62 | }
63 | }
64 |
65 | });
66 |
67 | InputHandler inputHandler = executionPlanRuntime.getInputHandler("cseEventStream");
68 | executionPlanRuntime.start();
69 | while (true) {
70 | inputHandler.send(new Object[]{"WSO2", 55.6f, 100});
71 | inputHandler.send(new Object[]{"IBM", 75.6f, 100});
72 | inputHandler.send(new Object[]{"WSO2", 100f, 80});
73 | inputHandler.send(new Object[]{"IBM", 75.6f, 100});
74 | inputHandler.send(new Object[]{"WSO2", 55.6f, 100});
75 | inputHandler.send(new Object[]{"IBM", 75.6f, 100});
76 | inputHandler.send(new Object[]{"WSO2", 100f, 80});
77 | inputHandler.send(new Object[]{"IBM", 75.6f, 100});
78 | }
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/performance/wso2/src/main/java/com/softleader/siddhi/performance/SimpleFilterMultipleQueryWithDisruptorPerformance.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.softleader.siddhi.performance;
17 |
18 | import org.wso2.siddhi.core.ExecutionPlanRuntime;
19 | import org.wso2.siddhi.core.SiddhiManager;
20 | import org.wso2.siddhi.core.event.Event;
21 | import org.wso2.siddhi.core.stream.input.InputHandler;
22 | import org.wso2.siddhi.core.stream.output.StreamCallback;
23 |
24 | public class SimpleFilterMultipleQueryWithDisruptorPerformance {
25 | private static int count = 0;
26 | private static volatile long start = System.currentTimeMillis();
27 |
28 | public static void main(String[] args) throws InterruptedException {
29 | SiddhiManager siddhiManager = new SiddhiManager();
30 |
31 | String executionPlan = "" +
32 | "@plan:parallel" +
33 | " " +
34 | "define stream cseEventStream (symbol string, price float, volume int);" +
35 | "define stream cseEventStream2 (symbol string, price float, volume int);" +
36 | "" +
37 | "@info(name = 'query1') " +
38 | "from cseEventStream[70 > price] " +
39 | "select * " +
40 | "insert into outputStream ;" +
41 | "" +
42 | "@info(name = 'query2') " +
43 | "from cseEventStream[volume > 90] " +
44 | "select * " +
45 | "insert into outputStream ;";
46 |
47 | ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(executionPlan);
48 |
49 | executionPlanRuntime.addCallback("outputStream", new StreamCallback() {
50 | private long chunk = 0;
51 | private long prevCount = 0;
52 |
53 | @Override
54 | public void receive(Event[] events) {
55 | count += events.length;
56 | long currentChunk = count / 2000000;
57 | if (currentChunk != chunk) {
58 | long end = System.currentTimeMillis();
59 | double tp = ((count - prevCount) * 1000.0 / (end - start));
60 | System.out.println("Throughput = " + tp + " Event/sec");
61 | start = end;
62 | chunk = currentChunk;
63 | prevCount = count;
64 | }
65 | }
66 |
67 | });
68 |
69 | InputHandler inputHandler = executionPlanRuntime.getInputHandler("cseEventStream");
70 | // InputHandler inputHandler2 = executionPlanRuntime.getInputHandler("cseEventStream2");
71 | executionPlanRuntime.start();
72 | while (true) {
73 | inputHandler.send(new Object[]{"WSO2", 55.6f, 100});
74 | inputHandler.send(new Object[]{"IBM", 75.6f, 100});
75 | inputHandler.send(new Object[]{"WSO2", 100f, 80});
76 | inputHandler.send(new Object[]{"IBM", 75.6f, 100});
77 | inputHandler.send(new Object[]{"WSO2", 55.6f, 100});
78 | inputHandler.send(new Object[]{"IBM", 75.6f, 100});
79 | inputHandler.send(new Object[]{"WSO2", 100f, 80});
80 | inputHandler.send(new Object[]{"IBM", 75.6f, 100});
81 | }
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/performance/wso2/siddhipom.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 | siddhi
20 | org.wso2.siddhi
21 | 3.0.0-SNAPSHOT
22 | ../../pom.xml
23 |
24 |
25 | 4.0.0
26 | siddhi-samples
27 | Siddhi Samples
28 | pom
29 |
30 |
31 | performance-samples
32 | quick-start-samples
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 | org.apache.maven.plugins
42 | maven-dependency-plugin
43 | false
44 |
45 |
46 | copy
47 | package
48 |
49 | copy
50 |
51 |
52 |
53 |
54 | org.apache.log4j.wso2
55 | log4j
56 | ${log4j.version}
57 | false
58 | ${project.basedir}/target/lib
59 |
60 |
61 |
62 | org.wso2.lmax
63 | disruptor
64 | ${disruptor.version}
65 | false
66 | ${project.basedir}/target/lib
67 |
68 |
69 |
70 | org.antlr
71 | antlr4-runtime
72 | ${antlr.runtime.version}
73 | false
74 | ${project.basedir}/target/lib
75 |
76 |
77 |
78 | org.wso2.siddhi
79 | siddhi-core
80 | ${project.version}
81 | true
82 | ${project.basedir}/target/lib
83 |
84 |
85 |
86 | org.wso2.siddhi
87 | siddhi-query-api
88 | ${project.version}
89 | true
90 | ${project.basedir}/target/lib
91 |
92 |
93 |
94 | org.wso2.siddhi
95 | siddhi-query-compiler
96 | ${project.version}
97 | true
98 | ${project.basedir}/target/lib
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
--------------------------------------------------------------------------------