use of org.apache.lucene.benchmark.byTask.utils.Algorithm 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);
}
}
use of org.apache.lucene.benchmark.byTask.utils.Algorithm in project lucene-solr by apache.
the class TestPerfTasksParse method testParseExamples.
/** Test the parsing of example scripts **/
@SuppressWarnings("try")
public void testParseExamples() throws Exception {
// hackedy-hack-hack
boolean foundFiles = false;
final Path examplesDir = Paths.get(ConfLoader.class.getResource(".").toURI());
try (DirectoryStream<Path> stream = Files.newDirectoryStream(examplesDir, "*.alg")) {
for (Path path : stream) {
Config config = new Config(Files.newBufferedReader(path, StandardCharsets.UTF_8));
String contentSource = config.get("content.source", null);
if (contentSource != null) {
Class.forName(contentSource);
}
config.set("work.dir", createTempDir(LuceneTestCase.getTestClass().getSimpleName()).toAbsolutePath().toString());
config.set("content.source", MockContentSource.class.getName());
String dir = config.get("content.source", null);
if (dir != null) {
Class.forName(dir);
}
config.set("directory", RAMDirectory.class.getName());
if (config.get("line.file.out", null) != null) {
config.set("line.file.out", createTempFile("linefile", ".txt").toAbsolutePath().toString());
}
if (config.get("query.maker", null) != null) {
Class.forName(config.get("query.maker", null));
config.set("query.maker", MockQueryMaker.class.getName());
}
PerfRunData data = new PerfRunData(config);
try (Algorithm algo = new Algorithm(data)) {
}
foundFiles = true;
}
}
if (!foundFiles) {
fail("could not find any .alg files!");
}
}
use of org.apache.lucene.benchmark.byTask.utils.Algorithm 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);
}
}
Aggregations