<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=text/html;charset=iso-8859-1 http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 8.00.6001.18828"></HEAD>
<BODY style="PADDING-LEFT: 10px; PADDING-RIGHT: 10px; PADDING-TOP: 15px"
id=MailContainerBody leftMargin=0 topMargin=0 CanvasTabStop="true"
name="Compose message area">
<DIV><FONT face=Calibri>Group,</FONT></DIV>
<DIV><FONT face=Calibri>The following HelloWorld example is taken from the
example code coming with the latest Drools downloads. One modification is
the addition of the loop(10K times). Please note that the loading of the drl
file is outside of this loop. Our developer tells us that this same
example runs in 300milliseconds in Drools 2.0. Version 5.0 runs for
10 seconds. We have a large batch process that will suffer greatly if this is
something we can't work around. Any ideas for performance gains in 5.0 will be
greatly appreciated.</FONT></DIV>
<DIV><FONT face=Calibri></FONT> </DIV>
<DIV><FONT face=Calibri>Duane</FONT></DIV>
<DIV><FONT face=Calibri><A
href="mailto:duane@proqualitysoft.com">duane@proqualitysoft.com</A></FONT></DIV>
<DIV><FONT face=Calibri></FONT> </DIV>
<DIV><FONT face=Calibri>public static final void main(final String[] args)
throws Exception {<BR> final KnowledgeBuilder kbuilder =
KnowledgeBuilderFactory.newKnowledgeBuilder();</FONT></DIV>
<DIV><FONT face=Calibri></FONT> </DIV>
<DIV><FONT face=Calibri> // this will parse and compile in one
step<BR> kbuilder.add(ResourceFactory.newClassPathResource("HelloWorld.drl",<BR> HelloWorldExample.class),
ResourceType.DRL);</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Calibri> // Check the builder for
errors<BR> if (kbuilder.hasErrors())
{<BR> System.out.println(kbuilder.getErrors().toString());<BR> throw
new RuntimeException("Unable to compile
\"HelloWorld.drl\".");<BR> }</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Calibri> // get the compiled packages (which are
serializable)<BR> final Collection<KnowledgePackage> pkgs =
kbuilder.getKnowledgePackages();</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Calibri> // add the packages to a knowledgebase
(deploy the knowledge packages).<BR> final KnowledgeBase kbase =
KnowledgeBaseFactory.newKnowledgeBase();<BR> kbase.addKnowledgePackages(pkgs);</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Calibri> final StatefulKnowledgeSession ksession =
kbase.newStatefulKnowledgeSession();<BR> ksession.setGlobal("list",
new ArrayList<Object>());</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Calibri> ksession.addEventListener(new
DebugAgendaEventListener());<BR> ksession.addEventListener(new
DebugWorkingMemoryEventListener());</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Calibri> // setup the audit
logging<BR> KnowledgeRuntimeLogger logger =
KnowledgeRuntimeLoggerFactory<BR> .newFileLogger(ksession,
"log/helloworld");<BR> long starttime =
System.currentTimeMillis();<BR> for(int
u=0;u<10000;u++)<BR> {<BR> final Message message = new
Message();<BR> message.setMessage("Hello
World");<BR> message.setStatus(Message.HELLO);<BR> ksession.insert(message);<BR> ksession.fireAllRules();<BR> }<BR>
long endtime =
System.currentTimeMillis();<BR>
System.out.println("execution time is
"+(endtime-starttime));<BR> logger.close();</FONT></DIV>
<DIV> </DIV>
<DIV><FONT
face=Calibri> ksession.dispose();<BR> }</FONT></DIV></BODY></HTML>