001: package org.apache.lucene.benchmark.byTask.programmatic;
002:
003: /**
004: * Copyright 2005 The Apache Software Foundation
005: *
006: * Licensed under the Apache License, Version 2.0 (the "License");
007: * you may not use this file except in compliance with the License.
008: * You may obtain a copy of the License at
009: *
010: * http://www.apache.org/licenses/LICENSE-2.0
011: *
012: * Unless required by applicable law or agreed to in writing, software
013: * distributed under the License is distributed on an "AS IS" BASIS,
014: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015: * See the License for the specific language governing permissions and
016: * limitations under the License.
017: */
018:
019: import java.io.IOException;
020: import java.util.Properties;
021:
022: import org.apache.lucene.benchmark.byTask.PerfRunData;
023: import org.apache.lucene.benchmark.byTask.tasks.AddDocTask;
024: import org.apache.lucene.benchmark.byTask.tasks.CloseIndexTask;
025: import org.apache.lucene.benchmark.byTask.tasks.CreateIndexTask;
026: import org.apache.lucene.benchmark.byTask.tasks.RepSumByNameTask;
027: import org.apache.lucene.benchmark.byTask.tasks.TaskSequence;
028: import org.apache.lucene.benchmark.byTask.utils.Config;
029:
030: /**
031: * Sample performance test written programatically - no algorithm file is needed here.
032: */
033: public class Sample {
034:
035: /**
036: * @param args
037: * @throws Exception
038: * @throws IOException
039: */
040: public static void main(String[] args) throws Exception {
041: Properties p = initProps();
042: Config conf = new Config(p);
043: PerfRunData runData = new PerfRunData(conf);
044:
045: // 1. top sequence
046: TaskSequence top = new TaskSequence(runData, null, null, false); // top level, not parralel
047:
048: // 2. task to create the index
049: CreateIndexTask create = new CreateIndexTask(runData);
050: top.addTask(create);
051:
052: // 3. task seq to add 500 docs (order matters - top to bottom - add seq to top, only then add to seq)
053: TaskSequence seq1 = new TaskSequence(runData, "AddDocs", top,
054: false);
055: seq1.setRepetitions(500);
056: seq1.setNoChildReport();
057: top.addTask(seq1);
058:
059: // 4. task to add the doc
060: AddDocTask addDoc = new AddDocTask(runData);
061: //addDoc.setParams("1200"); // doc size limit if supported
062: seq1.addTask(addDoc); // order matters 9see comment above)
063:
064: // 5. task to close the index
065: CloseIndexTask close = new CloseIndexTask(runData);
066: top.addTask(close);
067:
068: // task to report
069: RepSumByNameTask rep = new RepSumByNameTask(runData);
070: top.addTask(rep);
071:
072: // print algorithm
073: System.out.println(top.toString());
074:
075: // execute
076: top.doLogic();
077: }
078:
079: // Sample programmatic settings. Could also read from file.
080: private static Properties initProps() {
081: Properties p = new Properties();
082: p.setProperty("task.max.depth.log", "3");
083: p
084: .setProperty("max.buffered",
085: "buf:10:10:100:100:10:10:100:100");
086: p
087: .setProperty("doc.maker",
088: "org.apache.lucene.benchmark.byTask.feeds.ReutersDocMaker");
089: p.setProperty("doc.add.log.step", "2000");
090: p.setProperty("doc.delete.log.step", "2000");
091: p.setProperty("doc.delete.step", "8");
092: p.setProperty("analyzer",
093: "org.apache.lucene.analysis.standard.StandardAnalyzer");
094: p.setProperty("doc.term.vector", "false");
095: p.setProperty("directory", "FSDirectory");
096: p
097: .setProperty("query.maker",
098: "org.apache.lucene.benchmark.byTask.feeds.ReutersQueryMaker");
099: p.setProperty("doc.stored", "true");
100: p.setProperty("docs.dir", "reuters-out");
101: p.setProperty("compound",
102: "cmpnd:true:true:true:true:false:false:false:false");
103: p.setProperty("doc.tokenized", "true");
104: p
105: .setProperty("merge.factor",
106: "mrg:10:100:10:100:10:100:10:100");
107: return p;
108: }
109:
110: }
|