Search in sources :

Example 1 with PerfTask

use of org.apache.lucene.benchmark.byTask.tasks.PerfTask in project lucene-solr by apache.

the class Algorithm method extractTasks.

private void extractTasks(ArrayList<PerfTask> extrct, TaskSequence seq) {
    if (seq == null)
        return;
    extrct.add(seq);
    ArrayList<PerfTask> t = sequence.getTasks();
    if (t == null)
        return;
    for (final PerfTask p : t) {
        if (p instanceof TaskSequence) {
            extractTasks(extrct, (TaskSequence) p);
        } else {
            extrct.add(p);
        }
    }
}
Also used : TaskSequence(org.apache.lucene.benchmark.byTask.tasks.TaskSequence) PerfTask(org.apache.lucene.benchmark.byTask.tasks.PerfTask)

Example 2 with PerfTask

use of org.apache.lucene.benchmark.byTask.tasks.PerfTask in project lucene-solr by apache.

the class TestPerfTasksParse method testParseParallelTaskSequenceRepetition.

/** Test the repetiotion parsing for parallel tasks */
public void testParseParallelTaskSequenceRepetition() throws Exception {
    String taskStr = "AddDoc";
    String parsedTasks = "[ " + taskStr + " ] : 1000";
    Benchmark benchmark = new Benchmark(new StringReader(propPart + parsedTasks));
    Algorithm alg = benchmark.getAlgorithm();
    ArrayList<PerfTask> algTasks = alg.extractTasks();
    boolean foundAdd = false;
    for (final PerfTask task : algTasks) {
        if (task.toString().indexOf(taskStr) >= 0) {
            foundAdd = true;
        }
        if (task instanceof TaskSequence) {
            assertEquals("repetions should be 1000 for " + parsedTasks, 1000, ((TaskSequence) task).getRepetitions());
            assertTrue("sequence for " + parsedTasks + " should be parallel!", ((TaskSequence) task).isParallel());
        }
        assertTrue("Task " + taskStr + " was not found in " + alg.toString(), foundAdd);
    }
}
Also used : TaskSequence(org.apache.lucene.benchmark.byTask.tasks.TaskSequence) StringReader(java.io.StringReader) Algorithm(org.apache.lucene.benchmark.byTask.utils.Algorithm) PerfTask(org.apache.lucene.benchmark.byTask.tasks.PerfTask)

Example 3 with PerfTask

use of org.apache.lucene.benchmark.byTask.tasks.PerfTask in project lucene-solr by apache.

the class TestPerfTasksParse method testParseTaskSequenceRepetition.

/** Test the repetiotion parsing for sequential  tasks */
public void testParseTaskSequenceRepetition() throws Exception {
    String taskStr = "AddDoc";
    String parsedTasks = "{ " + taskStr + " } : 1000";
    Benchmark benchmark = new Benchmark(new StringReader(propPart + parsedTasks));
    Algorithm alg = benchmark.getAlgorithm();
    ArrayList<PerfTask> algTasks = alg.extractTasks();
    boolean foundAdd = false;
    for (final PerfTask task : algTasks) {
        if (task.toString().indexOf(taskStr) >= 0) {
            foundAdd = true;
        }
        if (task instanceof TaskSequence) {
            assertEquals("repetions should be 1000 for " + parsedTasks, 1000, ((TaskSequence) task).getRepetitions());
            assertFalse("sequence for " + parsedTasks + " should be sequential!", ((TaskSequence) task).isParallel());
        }
        assertTrue("Task " + taskStr + " was not found in " + alg.toString(), foundAdd);
    }
}
Also used : TaskSequence(org.apache.lucene.benchmark.byTask.tasks.TaskSequence) StringReader(java.io.StringReader) Algorithm(org.apache.lucene.benchmark.byTask.utils.Algorithm) PerfTask(org.apache.lucene.benchmark.byTask.tasks.PerfTask)

Aggregations

PerfTask (org.apache.lucene.benchmark.byTask.tasks.PerfTask)3 TaskSequence (org.apache.lucene.benchmark.byTask.tasks.TaskSequence)3 StringReader (java.io.StringReader)2 Algorithm (org.apache.lucene.benchmark.byTask.utils.Algorithm)2