add --shared
[pylucene.git] / lucene-java-3.4.0 / lucene / contrib / benchmark / src / java / org / apache / lucene / benchmark / byTask / tasks / RepAllTask.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 all statistics with no aggregations.
28  * <br>Other side effects: None.
29  */
30 public class RepAllTask extends ReportTask {
31
32   public RepAllTask(PerfRunData runData) {
33     super(runData);
34    }
35
36   @Override
37   public int doLogic() throws Exception {
38     Report rp = reportAll(getRunData().getPoints().taskStats());
39     
40     System.out.println();
41     System.out.println("------------> Report All ("+rp.getSize()+" out of "+rp.getOutOf()+")");
42     System.out.println(rp.getText());
43     System.out.println();
44     return 0;
45   }
46   
47   /**
48    * Report detailed statistics as a string
49    * @return the report
50    */
51   protected Report reportAll(List<TaskStats> taskStats) {
52     String longestOp = longestOp(taskStats);
53     boolean first = true;
54     StringBuilder sb = new StringBuilder();
55     sb.append(tableTitle(longestOp));
56     sb.append(newline);
57     int reported = 0;
58     for (final TaskStats stat : taskStats) {
59       if (stat.getElapsed()>=0) { // consider only tasks that ended
60         if (!first) {
61           sb.append(newline);
62         }
63         first = false;
64         String line = taskReportLine(longestOp, stat);
65         reported++;
66         if (taskStats.size()>2 && reported%2==0) {
67           line = line.replaceAll("   "," - ");
68         }
69         sb.append(line);
70       }
71     }
72     String reptxt = (reported==0 ? "No Matching Entries Were Found!" : sb.toString());
73     return new Report(reptxt,reported,reported,taskStats.size());
74   }
75
76 }