lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yo...@apache.org
Subject svn commit: r467843 - /lucene/java/trunk/src/test/org/apache/lucene/search/TestScorerPerf.java
Date Thu, 26 Oct 2006 02:51:26 GMT
Author: yonik
Date: Wed Oct 25 19:51:25 2006
New Revision: 467843

URL: http://svn.apache.org/viewvc?view=rev&rev=467843
Log:
added nested conjunction tests: LUCENE-693

Modified:
    lucene/java/trunk/src/test/org/apache/lucene/search/TestScorerPerf.java

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestScorerPerf.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/TestScorerPerf.java?view=diff&rev=467843&r1=467842&r2=467843
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestScorerPerf.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestScorerPerf.java Wed Oct 25 19:51:25
2006
@@ -159,6 +159,41 @@
     return ret;
   }
 
+  public int doNestedConjunctions(int iter, int maxOuterClauses, int maxClauses) throws IOException
{
+    int ret=0;
+
+    for (int i=0; i<iter; i++) {
+      int oClauses = r.nextInt(maxOuterClauses-1)+2;
+      BooleanQuery oq = new BooleanQuery();
+      BitSet result=null;
+
+      for (int o=0; o<oClauses; o++) {
+
+      int nClauses = r.nextInt(maxClauses-1)+2; // min 2 clauses
+      BooleanQuery bq = new BooleanQuery();
+      for (int j=0; j<nClauses; j++) {
+        result = addClause(bq,result);
+      }
+
+      oq.add(bq, BooleanClause.Occur.MUST);
+      if (validate) {
+
+      }
+      } // outer
+
+
+      CountingHitCollector hc = validate ? new MatchingHitCollector(result)
+                                         : new CountingHitCollector();
+      s.search(oq, hc);
+      ret += hc.getSum();
+      if (validate) assertEquals(result.cardinality(), hc.getCount());
+      // System.out.println(hc.getCount());
+    }
+
+    return ret;
+  }
+
+  
   public int doTermConjunctions(IndexSearcher s,
                                 int termsInIndex,
                                 int maxClauses,
@@ -232,6 +267,7 @@
     validate=true;
     sets=randBitSets(1000,10);
     doConjunctions(10000,5);
+    doNestedConjunctions(10000,3,3);
     s.close();
   }
 
@@ -247,6 +283,17 @@
     System.out.println("milliseconds="+(end-start));
   }
 
+  public void testNestedConjunctionPerf() throws Exception {
+    createDummySearcher();
+    validate=false;
+    sets=randBitSets(32,1000000);
+    long start = System.currentTimeMillis();
+    doNestedConjunctions(500,3,3);
+    long end = System.currentTimeMillis();
+    s.close();
+    System.out.println("milliseconds="+(end-start));
+  }
+
   public void testConjunctionTerms() throws Exception {
     RAMDirectory dir = new RAMDirectory();
     System.out.println("Creating index");
@@ -267,11 +314,11 @@
     s = new IndexSearcher(dir);
     System.out.println("Starting performance test");
     long start = System.currentTimeMillis();
-    doNestedTermConjunctions(s,25,4,6,1000);
+    doNestedTermConjunctions(s,25,5,5,1000);
     long end = System.currentTimeMillis();
     s.close();
     System.out.println("milliseconds="+(end-start));
   }
-   ***/
+  ***/
 
 }



Mime
View raw message