[jboss-svn-commits] JBL Code SVN: r12988 - labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/sequential.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Sun Jul 1 22:35:24 EDT 2007


Author: michael.neale at jboss.com
Date: 2007-07-01 22:35:24 -0400 (Sun, 01 Jul 2007)
New Revision: 12988

Added:
   labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/sequential/rule_generator.rb
Modified:
   labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/sequential/SequentialTest.java
Log:
debugging sequential

Modified: labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/sequential/SequentialTest.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/sequential/SequentialTest.java	2007-07-02 02:32:35 UTC (rev 12987)
+++ labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/sequential/SequentialTest.java	2007-07-02 02:35:24 UTC (rev 12988)
@@ -10,6 +10,7 @@
 import org.drools.RuleBase;
 import org.drools.RuleBaseConfiguration;
 import org.drools.RuleBaseFactory;
+import org.drools.StatefulSession;
 import org.drools.StatelessSession;
 import org.drools.WorkingMemory;
 import org.drools.compiler.PackageBuilder;
@@ -53,7 +54,46 @@
                       list.size() );
 
     }
+    
+    public void FIXME_testProfile() throws Exception {
 
+        // postponed while I sort out KnowledgeHelperFixer
+        final PackageBuilder builder = new PackageBuilder();
+        builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "sequentialProfile.drl" ) ) );
+        final Package pkg = builder.getPackage();
+
+        RuleBaseConfiguration conf = new RuleBaseConfiguration();
+        conf.setSequential( true );
+        final RuleBase ruleBase = getRuleBase( conf );
+        ruleBase.addPackage( pkg );
+        final StatelessSession session = ruleBase.newStatelessSession();
+
+        
+        final List list = new ArrayList();
+        session.setGlobal( "list",
+                           list );
+        
+        Object[] data = new Object[50000];
+        for ( int i = 0; i < data.length; i++ ) {
+            
+            if (i % 2 == 0) {
+                final Person p = new Person( "p" + i,
+                "stilton" );
+                data[i] = p;
+            } else {
+                    data[i] = new Cheese( "cheddar",
+                                i );
+            }
+        }
+        
+        long start = System.currentTimeMillis();
+        session.execute( data );
+        System.out.println("Time for seq:" + (System.currentTimeMillis() - start));
+        assertTrue( 
+                      list.size() > 0);
+
+    }    
+
     protected RuleBase getRuleBase() throws Exception {
 
         return RuleBaseFactory.newRuleBase( RuleBase.RETEOO,

Added: labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/sequential/rule_generator.rb
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/sequential/rule_generator.rb	                        (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/sequential/rule_generator.rb	2007-07-02 02:35:24 UTC (rev 12988)
@@ -0,0 +1,34 @@
+OUTPUT="rules.drl"
+
+if File.exists? OUTPUT then File.delete(OUTPUT) end
+
+f = File.new(OUTPUT, "w")
+
+
+for i in 1..200
+
+	s =  "
+	
+	rule \"Cheese_#{i}\"	
+		when
+			$c : Cheese( price == #{i} )
+		then 
+			list.add( $c.getType() );
+	end
+	
+	rule \"Person and cheese_#{i}\"
+		when 
+			$p : Person(name == \"p#{i}\")
+			$c : Cheese(price == 1)
+		then
+			list.add($p.getName());
+		
+	end
+	"
+	f.write s
+
+
+
+end
+
+f.close
\ No newline at end of file




More information about the jboss-svn-commits mailing list