<div>Hi guys,<br></div><div></div><div>We made some experiments with Drools Fusion and we wonder if there is any way to speed it up. In our experiments, we detected complex events in streams of stock tickers and got times significantly slower with Drools than with other CEP systems (and also higher memory consumption in the same order of magnitude):</div>

<div></div><div>Number of events        Drools 5.0 Fusion        Esper 3.1.0        Etalis with SWI Prolog        Etalis with Yap Prolog<br>10000        1179        453        328        265 (time in miliseconds to process the stream of events)<br>20000        2359        828        701        531<br>30000        3538        1141        1023        780<br>

40000        4718        1500        1356        1078<br>50000        5897        1813        1702        1329<br><br></div><div>I can provide some of our code if someone needs it (beside what I pasted below). </div><div>Please tell me if you know any obvious optimizations? Or if you think this is due to Java (vs. C in other implementations), or any other reasons.</div>

<div></div><div>Thank you, regards,</div><div>Paul Fodor </div><div></div><div>Our program has 5 rules to detect complex events:</div><div>fusion.drl:</div><div>rule &quot;experiment A -Rule 0/0&quot;<br>when<br> $ae1 :Event(symbol == 1, $Pr1 : price) and<br>

 $ce1 :Event(this after $ae1 , symbol == 1, price &gt; ($Pr1/1.2) )<br>then<br> //System.out.println(&quot;Ce1 fired !&quot;);<br>end<br>rule &quot;experiment A -Rule 0/1&quot;<br>when<br> (<br> $ae2 :Event(symbol == 2,$Pr2 : price) and<br>

 $ce2 : Event(this after $ae2 , symbol == 2,price &gt; ($Pr2/1.2) )<br> ) <br>then <br> //System.out.println(&quot;Ce2 fired !&quot;);<br>end<br>rule &quot;experiment A -Rule1&quot;<br>when<br> (<br> $ae1 :Event(symbol == 1, $Pr1 : price) and<br>

 $ce1 :Event(this after $ae1 , symbol == 1, price &gt; ($Pr1/1.2) )<br> ) <br>         or <br> (<br> $ae2 :Event(symbol == 2,$Pr2 : price) and<br> $ce2 : Event(this after $ae2 , symbol == 2,price &gt; ($Pr2/1.2) )<br> ) <br>then<br>

 //System.out.println(&quot;Ce3 fired !&quot;);<br>end<br><br>rule &quot;experiment A -Rule4&quot;<br>when<br> (<br> $ae1 :Event(symbol == 1, $Pr1 : price) and<br> $ce1 :Event(this after $ae1 , symbol == 1, price &gt; ($Pr1/1.2) )<br>

 ) <br>         and<br> (<br> $ae2 :Event(symbol == 2,$Pr2 : price) and<br> $ce2 : Event(this after $ae2 , symbol == 2,price &gt; ($Pr2/1.2) , this after[0,20m] $ce1 )<br> )<br>then<br> //System.out.println(&quot;Ce4 fired !&quot;);<br>

end<br><br>rule &quot;experiment A -Rule5&quot;<br>when<br> (<br> $ae1 :Event(symbol == 1, $Pr1 : price) and <br> $ce1 :Event(this after $ae1 , symbol == 1, price &gt; ($Pr1/1.2))<br> ) <br>         and<br> (<br> $ae2 :Event(symbol == 2,$Pr2 : price)  and<br>

 $ce2 : Event(this after $ae2 , symbol == 2,price &gt; ($Pr2/1.2) , this overlaps $ce1)<br> )<br>then<br> //System.out.println(&quot;Ce5 fired !&quot;);<br>end <br><br></div><div>We have an Event class for events with its parameters and an EventStream class to fire the events:</div>

<div>EventStream.java:</div><div>...</div><div>import org.drools.runtime.StatefulKnowledgeSession;<br>public class EventStream {<br> public StatefulKnowledgeSession get_working_session() { return ksession;}<br></div><div>

...</div><div> void generateEventStream(double duration, double p)  { <br>         ...<br>         //Drools <br>         Event temp = new Event(symbol,currValue);<br>         ksession.insert(temp); <br>         ...<br> }<br>}<br><br></div>