I have tried couple of things as suggested by the rules user list. It has
improved the execution time of hello world example to some extent.
1. Moving fireallRules() out of the loop - helped very little, execution
time was almost same(150 millisecs less). - 10.35 secs
2. Commenting out the audit logger used in the example - cut the execution
time by half 5.67 secs
3. Removing system.outs from rules - reduces 2 secs of execution time -
3.433
The final execution time for HelloWorldExample in drools5.0 is 3.4 secs and
in Java is 256 milli secs. (I am attaching the java version of drools
example also to this email) .
package org.drools.examples;
import java.util.List;
import org.drools.examples.HelloWorldExample.Message;
public class HelloWorldJavaExample {
public static long starttime = 0;
public static long endtime =0;
public static void hello(Message message)
{
System.out.println(message.getMessage());
message.setMessage("Good Bye Cruel World");
message.setStatus(Message.GOODBYE);
goodbye(message);
}
public static void goodbye(Message message)
{
System.out.println(message.getMessage());
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
starttime = System.currentTimeMillis();
for(int u=0;u<10000;u++)
{
final Message message = new Message();
message.setMessage("Hello World");
message.setStatus(Message.HELLO);
if(message.getMessage().equalsIgnoreCase("Hello
World"))
{
hello(message);
}
}
endtime = System.currentTimeMillis();
System.out.println("execution time in main is
"+(endtime-starttime));
}
public static class Message {
public static final int HELLO = 0;
public static final int GOODBYE = 1;
private String message;
private int status;
public Message() {
}
public String getMessage() {
return this.message;
}
public void setMessage(final String message) {
this.message = message;
}
public int getStatus() {
return this.status;
}
public void setStatus(final int status) {
this.status = status;
}
public static Message doSomething(Message message) {
return message;
}
public boolean isSomething(String msg, List list) {
list.add(this);
return this.message.equals(msg);
}
}
}
thanks for your suggestions.
ABRA2