01: package org.apache.lucene.benchmark.byTask.tasks;
02:
03: /**
04: * Licensed to the Apache Software Foundation (ASF) under one or more
05: * contributor license agreements. See the NOTICE file distributed with
06: * this work for additional information regarding copyright ownership.
07: * The ASF licenses this file to You under the Apache License, Version 2.0
08: * (the "License"); you may not use this file except in compliance with
09: * 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.Iterator;
21: import java.util.List;
22:
23: import org.apache.lucene.benchmark.byTask.PerfRunData;
24: import org.apache.lucene.benchmark.byTask.stats.Report;
25: import org.apache.lucene.benchmark.byTask.stats.TaskStats;
26:
27: /**
28: * Report all statistics with no aggregations.
29: * <br>Other side effects: None.
30: */
31: public class RepAllTask extends ReportTask {
32:
33: public RepAllTask(PerfRunData runData) {
34: super (runData);
35: }
36:
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()
42: + " out of " + rp.getOutOf() + ")");
43: System.out.println(rp.getText());
44: System.out.println();
45: return 0;
46: }
47:
48: /**
49: * Report detailed statistics as a string
50: * @return the report
51: */
52: protected Report reportAll(List taskStats) {
53: String longestOp = longestOp(taskStats.iterator());
54: boolean first = true;
55: StringBuffer sb = new StringBuffer();
56: sb.append(tableTitle(longestOp));
57: sb.append(newline);
58: int reported = 0;
59: Iterator it = taskStats.iterator();
60: while (it.hasNext()) {
61: TaskStats stat = (TaskStats) it.next();
62: if (stat.getElapsed() >= 0) { // consider only tasks that ended
63: if (!first) {
64: sb.append(newline);
65: }
66: first = false;
67: String line = taskReportLine(longestOp, stat);
68: reported++;
69: if (taskStats.size() > 2 && reported % 2 == 0) {
70: line = line.replaceAll(" ", " - ");
71: }
72: sb.append(line);
73: }
74: }
75: String reptxt = (reported == 0 ? "No Matching Entries Were Found!"
76: : sb.toString());
77: return new Report(reptxt, reported, reported, taskStats.size());
78: }
79:
80: }
|