pylucene 3.5.0-3
[pylucene.git] / lucene-java-3.5.0 / lucene / contrib / benchmark / src / java / org / apache / lucene / benchmark / byTask / programmatic / Sample.java
1 package org.apache.lucene.benchmark.byTask.programmatic;
2
3 /**
4  * Copyright 2005 The Apache Software Foundation
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *     http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18
19 import java.io.IOException;
20 import java.util.Properties;
21
22 import org.apache.lucene.benchmark.byTask.PerfRunData;
23 import org.apache.lucene.benchmark.byTask.tasks.AddDocTask;
24 import org.apache.lucene.benchmark.byTask.tasks.CloseIndexTask;
25 import org.apache.lucene.benchmark.byTask.tasks.CreateIndexTask;
26 import org.apache.lucene.benchmark.byTask.tasks.RepSumByNameTask;
27 import org.apache.lucene.benchmark.byTask.tasks.TaskSequence;
28 import org.apache.lucene.benchmark.byTask.utils.Config;
29
30 /**
31  * Sample performance test written programmatically - no algorithm file is needed here.
32  */
33 public class Sample {
34
35   /**
36    * @param args
37    * @throws Exception 
38    * @throws IOException 
39    */
40   public static void main(String[] args) throws Exception {
41     Properties p = initProps();
42     Config conf = new Config(p);
43     PerfRunData runData = new PerfRunData(conf);
44     
45     // 1. top sequence
46     TaskSequence top = new TaskSequence(runData,null,null,false); // top level, not parallel
47     
48     // 2. task to create the index
49     CreateIndexTask create = new CreateIndexTask(runData);
50     top.addTask(create);
51     
52     // 3. task seq to add 500 docs (order matters - top to bottom - add seq to top, only then add to seq)
53     TaskSequence seq1 = new TaskSequence(runData,"AddDocs",top,false);
54     seq1.setRepetitions(500);
55     seq1.setNoChildReport();
56     top.addTask(seq1);
57
58     // 4. task to add the doc
59     AddDocTask addDoc = new AddDocTask(runData);
60     //addDoc.setParams("1200"); // doc size limit if supported
61     seq1.addTask(addDoc); // order matters 9see comment above)
62
63     // 5. task to close the index
64     CloseIndexTask close = new CloseIndexTask(runData);
65     top.addTask(close);
66
67     // task to report
68     RepSumByNameTask rep = new RepSumByNameTask(runData);
69     top.addTask(rep);
70
71     // print algorithm
72     System.out.println(top.toString());
73     
74     // execute
75     top.doLogic();
76     top.close();
77   }
78
79   // Sample programmatic settings. Could also read from file.
80   private static Properties initProps() {
81     Properties p = new Properties();
82     p.setProperty ( "task.max.depth.log"  , "3" );
83     p.setProperty ( "max.buffered"        , "buf:10:10:100:100:10:10:100:100" );
84     p.setProperty ( "doc.maker"           , "org.apache.lucene.benchmark.byTask.feeds.ReutersContentSource" );
85     p.setProperty ( "log.step"            , "2000" );
86     p.setProperty ( "doc.delete.step"     , "8" );
87     p.setProperty ( "analyzer"            , "org.apache.lucene.analysis.standard.StandardAnalyzer" );
88     p.setProperty ( "doc.term.vector"     , "false" );
89     p.setProperty ( "directory"           , "FSDirectory" );
90     p.setProperty ( "query.maker"         , "org.apache.lucene.benchmark.byTask.feeds.ReutersQueryMaker" );
91     p.setProperty ( "doc.stored"          , "true" );
92     p.setProperty ( "docs.dir"            , "reuters-out" );
93     p.setProperty ( "compound"            , "cmpnd:true:true:true:true:false:false:false:false" );
94     p.setProperty ( "doc.tokenized"       , "true" );
95     p.setProperty ( "merge.factor"        , "mrg:10:100:10:100:10:100:10:100" );
96     return p;
97   }
98   
99   
100
101 }