| See attached project, DroolsBilling. You can build it with Maven from the project directory: mvn clean package To run it after building: java -jar target/DroolsBilling-1.0.jar <numRules> <numPhoneNumbersPerThread> $ java -server -jar target/DroolsBilling-1.0.jar 100 100000 Rules load time: 3482ms Rules execution time: 732ms, per number: 0.00732ms Rules execution time: 731ms, per number: 0.00731ms Rules execution time: 746ms, per number: 0.00746ms Rules execution time: 760ms, per number: 0.0076ms Rules execution time: 832ms, per number: 0.00832ms Rules execution time: 623ms, per number: 0.00623ms Rules execution time: 600ms, per number: 0.0060ms Rules execution time: 632ms, per number:
0.00632ms Rules execution time: 630ms, per number: 0.0063ms Rules execution time: 607ms, per number: 0.00607ms DONE! At higher numbers of rules you have to increase the perm gen and heap memory: $ java -server -Xmx1024M -XX:MaxPermSize=128M -jar target/DroolsBilling-1.0.jar 10000 100000 Rules load time: 58317ms Rules execution time: 1580ms, per number: 0.0158ms Rules execution time: 1580ms, per number: 0.0158ms Rules execution time: 1586ms, per number: 0.01586ms Rules execution time: 2493ms, per number: 0.02493ms Rules execution time: 2502ms, per number: 0.02502ms Rules execution time: 1360ms, per number: 0.0136ms Rules execution time: 1358ms, per number: 0.01358ms Rules execution time: 1376ms, per number: 0.01376ms Rules execution time: 473ms, per number:
0.00473ms Rules execution time: 489ms, per number: 0.00489ms DONE! As you can see the time to process one phone number is lower than 1 minute. :) The example uses 5 concurrent threads and was executed on a 4 core machine. A Sample.drl is included that shows the format of the rules generated, basically this: rule "PhoneNumber000000000" when p : PhoneNumber( digit0 == '0', digit1 == '0', digit2 == '0', digit3 == '0', digit4 == '0', digit5 == '0', digit6 == '0', digit7 == '0', digit8 == '0', digit9 == '0') then p.setPrice(0.0); end They
should be substantially similar to the rules generated behind the decision table you've given, so the performance should be similar. As you can see from the times above, rule creation is expensive but execution is cheap. As Mark said, reuse the KnowledgeBase.
|