Search in sources :

Example 6 with TaskStats

use of org.apache.lucene.benchmark.byTask.stats.TaskStats in project lucene-solr by apache.

the class RepSumByPrefRoundTask method reportSumByPrefixRound.

protected Report reportSumByPrefixRound(List<TaskStats> taskStats) {
    // aggregate by task name and by round
    int reported = 0;
    LinkedHashMap<String, TaskStats> p2 = new LinkedHashMap<>();
    for (final TaskStats stat1 : taskStats) {
        if (stat1.getElapsed() >= 0 && stat1.getTask().getName().startsWith(prefix)) {
            // only ended tasks with proper name
            reported++;
            String name = stat1.getTask().getName();
            // group by round
            String rname = stat1.getRound() + "." + name;
            TaskStats stat2 = p2.get(rname);
            if (stat2 == null) {
                try {
                    stat2 = stat1.clone();
                } catch (CloneNotSupportedException e) {
                    throw new RuntimeException(e);
                }
                p2.put(rname, stat2);
            } else {
                stat2.add(stat1);
            }
        }
    }
    // now generate report from secondary list p2    
    return genPartialReport(reported, p2, taskStats.size());
}
Also used : TaskStats(org.apache.lucene.benchmark.byTask.stats.TaskStats) LinkedHashMap(java.util.LinkedHashMap)

Example 7 with TaskStats

use of org.apache.lucene.benchmark.byTask.stats.TaskStats in project lucene-solr by apache.

the class RepAllTask method reportAll.

/**
   * Report detailed statistics as a string
   * @return the report
   */
protected Report reportAll(List<TaskStats> taskStats) {
    String longestOp = longestOp(taskStats);
    boolean first = true;
    StringBuilder sb = new StringBuilder();
    sb.append(tableTitle(longestOp));
    sb.append(newline);
    int reported = 0;
    for (final TaskStats stat : taskStats) {
        if (stat.getElapsed() >= 0) {
            // consider only tasks that ended
            if (!first) {
                sb.append(newline);
            }
            first = false;
            String line = taskReportLine(longestOp, stat);
            reported++;
            if (taskStats.size() > 2 && reported % 2 == 0) {
                line = line.replaceAll("   ", " - ");
            }
            sb.append(line);
        }
    }
    String reptxt = (reported == 0 ? "No Matching Entries Were Found!" : sb.toString());
    return new Report(reptxt, reported, reported, taskStats.size());
}
Also used : Report(org.apache.lucene.benchmark.byTask.stats.Report) TaskStats(org.apache.lucene.benchmark.byTask.stats.TaskStats)

Example 8 with TaskStats

use of org.apache.lucene.benchmark.byTask.stats.TaskStats in project lucene-solr by apache.

the class ReportTask method genPartialReport.

protected Report genPartialReport(int reported, LinkedHashMap<String, TaskStats> partOfTasks, int totalSize) {
    String longetOp = longestOp(partOfTasks.values());
    boolean first = true;
    StringBuilder sb = new StringBuilder();
    sb.append(tableTitle(longetOp));
    sb.append(newline);
    int lineNum = 0;
    for (final TaskStats stat : partOfTasks.values()) {
        if (!first) {
            sb.append(newline);
        }
        first = false;
        String line = taskReportLine(longetOp, stat);
        lineNum++;
        if (partOfTasks.size() > 2 && lineNum % 2 == 0) {
            line = line.replaceAll("   ", " - ");
        }
        sb.append(line);
        int[] byTime = stat.getCountsByTime();
        if (byTime != null) {
            sb.append(newline);
            int end = -1;
            for (int i = byTime.length - 1; i >= 0; i--) {
                if (byTime[i] != 0) {
                    end = i;
                    break;
                }
            }
            if (end != -1) {
                sb.append("  by time:");
                for (int i = 0; i < end; i++) {
                    sb.append(' ').append(byTime[i]);
                }
            }
        }
    }
    String reptxt = (reported == 0 ? "No Matching Entries Were Found!" : sb.toString());
    return new Report(reptxt, partOfTasks.size(), reported, totalSize);
}
Also used : Report(org.apache.lucene.benchmark.byTask.stats.Report) TaskStats(org.apache.lucene.benchmark.byTask.stats.TaskStats)

Example 9 with TaskStats

use of org.apache.lucene.benchmark.byTask.stats.TaskStats in project lucene-solr by apache.

the class TaskSequence method doParallelTasks.

private int doParallelTasks() throws Exception {
    final TaskStats stats = getRunData().getPoints().getCurrentStats();
    initTasksArray();
    ParallelTask[] t = runningParallelTasks = new ParallelTask[repetitions * tasks.size()];
    // prepare threads
    int index = 0;
    for (int k = 0; k < repetitions; k++) {
        for (int i = 0; i < tasksArray.length; i++) {
            final PerfTask task = tasksArray[i].clone();
            t[index++] = new ParallelTask(task);
        }
    }
    // run threads
    startThreads(t);
    if (stopNow) {
        for (ParallelTask task : t) {
            task.task.stopNow();
        }
    }
    // wait for all threads to complete
    int count = 0;
    for (int i = 0; i < t.length; i++) {
        t[i].join();
        count += t[i].count;
        if (t[i].task instanceof TaskSequence) {
            TaskSequence sub = (TaskSequence) t[i].task;
            if (sub.countsByTime != null) {
                if (countsByTime == null) {
                    countsByTime = new int[sub.countsByTime.length];
                } else if (countsByTime.length < sub.countsByTime.length) {
                    countsByTime = ArrayUtil.grow(countsByTime, sub.countsByTime.length);
                }
                for (int j = 0; j < sub.countsByTime.length; j++) {
                    countsByTime[j] += sub.countsByTime[j];
                }
            }
        }
    }
    if (countsByTime != null) {
        stats.setCountsByTime(countsByTime, logByTimeMsec);
    }
    // return total count
    return count;
}
Also used : TaskStats(org.apache.lucene.benchmark.byTask.stats.TaskStats)

Example 10 with TaskStats

use of org.apache.lucene.benchmark.byTask.stats.TaskStats in project lucene-solr by apache.

the class RepSumByNameTask method reportSumByName.

/**
   * Report statistics as a string, aggregate for tasks named the same.
   * @return the report
   */
protected Report reportSumByName(List<TaskStats> taskStats) {
    // aggregate by task name
    int reported = 0;
    LinkedHashMap<String, TaskStats> p2 = new LinkedHashMap<>();
    for (final TaskStats stat1 : taskStats) {
        if (stat1.getElapsed() >= 0) {
            // consider only tasks that ended
            reported++;
            String name = stat1.getTask().getName();
            TaskStats stat2 = p2.get(name);
            if (stat2 == null) {
                try {
                    stat2 = stat1.clone();
                } catch (CloneNotSupportedException e) {
                    throw new RuntimeException(e);
                }
                p2.put(name, stat2);
            } else {
                stat2.add(stat1);
            }
        }
    }
    // now generate report from secondary list p2    
    return genPartialReport(reported, p2, taskStats.size());
}
Also used : TaskStats(org.apache.lucene.benchmark.byTask.stats.TaskStats) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

TaskStats (org.apache.lucene.benchmark.byTask.stats.TaskStats)11 LinkedHashMap (java.util.LinkedHashMap)4 Report (org.apache.lucene.benchmark.byTask.stats.Report)3 Points (org.apache.lucene.benchmark.byTask.stats.Points)1 Fields (org.apache.lucene.index.Fields)1 IndexReader (org.apache.lucene.index.IndexReader)1 MultiFields (org.apache.lucene.index.MultiFields)1 PostingsEnum (org.apache.lucene.index.PostingsEnum)1 Terms (org.apache.lucene.index.Terms)1 TermsEnum (org.apache.lucene.index.TermsEnum)1