add --shared
[pylucene.git] / lucene-java-3.4.0 / lucene / contrib / benchmark / src / java / org / apache / lucene / benchmark / byTask / tasks / RepSelectByPrefTask.java
1 package org.apache.lucene.benchmark.byTask.tasks;
2
3 /**
4  * Licensed to the Apache Software Foundation (ASF) under one or more
5  * contributor license agreements.  See the NOTICE file distributed with
6  * this work for additional information regarding copyright ownership.
7  * The ASF licenses this file to You under the Apache License, Version 2.0
8  * (the "License"); you may not use this file except in compliance with
9  * the License.  You may obtain a copy of the License at
10  *
11  *     http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19
20 import java.util.List;
21
22 import org.apache.lucene.benchmark.byTask.PerfRunData;
23 import org.apache.lucene.benchmark.byTask.stats.Report;
24 import org.apache.lucene.benchmark.byTask.stats.TaskStats;
25
26 /**
27  * Report by-name-prefix statistics with no aggregations.
28  * <br>Other side effects: None.
29  */
30 public class RepSelectByPrefTask extends RepSumByPrefTask {
31
32   public RepSelectByPrefTask(PerfRunData runData) {
33     super(runData);
34   }
35
36   @Override
37   public int doLogic() throws Exception {
38     Report rp = reportSelectByPrefix(getRunData().getPoints().taskStats());
39     
40     System.out.println();
41     System.out.println("------------> Report Select By Prefix ("+prefix+") ("+
42         rp.getSize()+" about "+rp.getReported()+" out of "+rp.getOutOf()+")");
43     System.out.println(rp.getText());
44     System.out.println();
45
46     return 0;
47   }
48   
49   protected Report reportSelectByPrefix(List<TaskStats> taskStats) {
50     String longestOp = longestOp(taskStats);
51     boolean first = true;
52     StringBuilder sb = new StringBuilder();
53     sb.append(tableTitle(longestOp));
54     sb.append(newline);
55     int reported = 0;
56     for (final TaskStats stat : taskStats) {
57       if (stat.getElapsed()>=0 && stat.getTask().getName().startsWith(prefix)) { // only ended tasks with proper name
58         reported++;
59         if (!first) {
60           sb.append(newline);
61         }
62         first = false;
63         String line = taskReportLine(longestOp,stat);
64         if (taskStats.size()>2 && reported%2==0) {
65           line = line.replaceAll("   "," - ");
66         }
67         sb.append(line);
68       }
69     }
70     String reptxt = (reported==0 ? "No Matching Entries Were Found!" : sb.toString());
71     return new Report(reptxt,reported,reported, taskStats.size());
72   }
73
74 }