I'd say to really show the speed of rules (as well as
their expressive power) the rules should be a bit more
complex. This would show two things: 1) the indexing
of the rete handles ever more complex scenarios
automatically, and 2) it's just easier to express
complex scenarios in rules. Josh, you mentioned that
your rules only create alpha nodes. That tells me
you're not exploiting the full power a rule engine can
offer.
So, try this:
class Person {
char letter;
int number;
}
class Place {
char letter;
int number;
int matchCapacity;
}
Rules:
If a Person.letter == Place.letter, match them;
If a Person.number.isOdd() and place.number.isEven()
and they're matched, UNmatch them.
If a Person.number.isEven() and place.number.isOdd()
and they're matched, UNmatch them.
If a Place is over matchCapacity, throw out a random
matched Person.
***
Try adding more rules, like "Places with the same
letter can share People, but only if their numbers are
within 2."
You'll find that as you try writing the pure java
equivalent, adding rules, it will become 1) harder to
optimize the java version well, and/or 2) difficult to
express the java clearly and sussinctly.
GreG
--- Mark Proctor <mproctor(a)codehaus.org> wrote:
A rule engine is java code, so well crafted java
code is always going to
outperformance a generic rule engine - if you
arrange all your caching
and indexing right. So I'm not sure what it is you
are trying to prove?
If you wanted to prove that drools was faster than
dump iteration and
lookup, try something that exploits the indexing.
Create 10K people and
200 places. Assign the people randomly to different
places - use a
String keyword to match the two. Then use the rule
engine to find all
the people matching all the places and then try the
same in java code.
Mark
Harsh Jetly wrote:
> Hi ,
> I have been given an assignment to show case the
situation where the
> performance of a rule engine will be better than
java code .
>
> My first question is ; Is this possible ?
>
> What I had done earlier was I sent an arraylist
and I used the 'from'
> clause , like Mark pointed out for the 'from'
statement pure iteration
> happens and the index is not created .
>
> So what I have done now is create a scenario
where I insert about 20,000
> objects and have 20 rules (each rule has 2 alpha
nodes ) . I do the same
> with java code (if-elses) and the java code wins
this competition hands
> down .
>
> Is there a breakthrough point where the rule
engine performs as well as the
> java code or even better ?
>
>
> Appreciate it
>
> Harsh
>
>
>
______________________________________________________________________
> _______________________________________________
> rules-dev mailing list
> rules-dev(a)lists.jboss.org
>
https://lists.jboss.org/mailman/listinfo/rules-dev
>
>
_______________________________________________
rules-dev mailing list
rules-dev(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-dev