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 by-name-prefix statistics with no aggregations.
29: * <br>Other side effects: None.
30: */
31: public class RepSelectByPrefTask extends RepSumByPrefTask {
32:
33: public RepSelectByPrefTask(PerfRunData runData) {
34: super (runData);
35: }
36:
37: public int doLogic() throws Exception {
38: Report rp = reportSelectByPrefix(getRunData().getPoints()
39: .taskStats());
40:
41: System.out.println();
42: System.out.println("------------> Report Select By Prefix ("
43: + prefix + ") (" + rp.getSize() + " about "
44: + rp.getReported() + " out of " + rp.getOutOf() + ")");
45: System.out.println(rp.getText());
46: System.out.println();
47:
48: return 0;
49: }
50:
51: protected Report reportSelectByPrefix(List taskStats) {
52: String longestOp = longestOp(taskStats.iterator());
53: boolean first = true;
54: StringBuffer sb = new StringBuffer();
55: sb.append(tableTitle(longestOp));
56: sb.append(newline);
57: int reported = 0;
58: for (Iterator it = taskStats.iterator(); it.hasNext();) {
59: TaskStats stat = (TaskStats) it.next();
60: if (stat.getElapsed() >= 0
61: && stat.getTask().getName().startsWith(prefix)) { // only ended tasks with proper name
62: reported++;
63: if (!first) {
64: sb.append(newline);
65: }
66: first = false;
67: String line = taskReportLine(longestOp, stat);
68: if (taskStats.size() > 2 && reported % 2 == 0) {
69: line = line.replaceAll(" ", " - ");
70: }
71: sb.append(line);
72: }
73: }
74: String reptxt = (reported == 0 ? "No Matching Entries Were Found!"
75: : sb.toString());
76: return new Report(reptxt, reported, reported, taskStats.size());
77: }
78:
79: }
|