1 package org.apache.lucene.benchmark.byTask.tasks;
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
20 import org.apache.lucene.benchmark.byTask.PerfRunData;
21 import org.apache.lucene.benchmark.byTask.stats.Report;
22 import org.apache.lucene.benchmark.byTask.stats.TaskStats;
24 import java.util.LinkedHashMap;
25 import java.util.List;
28 * Report by-name-prefix statistics aggregated by name.
29 * <br>Other side effects: None.
31 public class RepSumByPrefTask extends ReportTask {
33 public RepSumByPrefTask(PerfRunData runData) {
37 protected String prefix;
40 public int doLogic() throws Exception {
41 Report rp = reportSumByPrefix(getRunData().getPoints().taskStats());
44 System.out.println("------------> Report Sum By Prefix ("+prefix+") ("+
45 rp.getSize()+" about "+rp.getReported()+" out of "+rp.getOutOf()+")");
46 System.out.println(rp.getText());
52 protected Report reportSumByPrefix (List<TaskStats> taskStats) {
53 // aggregate by task name
55 LinkedHashMap<String,TaskStats> p2 = new LinkedHashMap<String,TaskStats>();
56 for (final TaskStats stat1 : taskStats) {
57 if (stat1.getElapsed()>=0 && stat1.getTask().getName().startsWith(prefix)) { // only ended tasks with proper name
59 String name = stat1.getTask().getName();
60 TaskStats stat2 = p2.get(name);
63 stat2 = (TaskStats) stat1.clone();
64 } catch (CloneNotSupportedException e) {
65 throw new RuntimeException(e);
73 // now generate report from secondary list p2
74 return genPartialReport(reported, p2, taskStats.size());
78 public void setPrefix(String prefix) {
83 * @see PerfTask#toString()
86 public String toString() {
87 return super.toString()+" "+prefix;