Commit 52766045 authored by Noric Couderc's avatar Noric Couderc

Fixed generation of benchmarks

Removed double iteration over all benchmarks to build the list of
benchmark indexes.

Also fixed a broken switch statement.
parent 611ffe2e
......@@ -8,11 +8,11 @@ import org.openjdk.jmh.runner.options.Options;
import org.openjdk.jmh.runner.options.OptionsBuilder;
import org.openjdk.jmh.runner.options.TimeValue;
import se.lth.cs.TraceLoader;
import se.lth.cs.bcgen.BCBenchmark;
import se.lth.cs.bcgen.BCBenchmarkPackage;
import java.io.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
......@@ -42,44 +42,48 @@ public class Main {
throws IOException, IllegalAccessException, InstantiationException,
ClassNotFoundException {
TraceLoader tl = new TraceLoader();
Stream<BCBenchmarkPackage<?>> benchmarks =
tl.readCsv(new FileReader(new File("test-dacapo.csv")), false);
List<BCBenchmarkPackage<?>> benchmarks =
tl.readCsv(new FileReader(new File("test-dacapo.csv")), false)
.collect(Collectors.toList());
FileOutputStream fo = new FileOutputStream("serialized-benchmarks");
ObjectOutputStream out = new ObjectOutputStream(fo);
out.writeObject(benchmarks.collect(Collectors.toList()));
out.writeObject(benchmarks);
List<Options> result = new ArrayList<>();
Map<String, Stream<Integer>> indexes =
tl.readCsvToIndexes(new FileReader(new File(fileName)), false);
Map<String, List<Integer>> indexes = new HashMap<>();
int index = 0;
for (BCBenchmarkPackage<?> b : benchmarks) {
String id = b.getInterfaceIdentifier();
if (indexes.containsKey(id)) {
indexes.get(id).add(index);
} else {
indexes.put(id, new ArrayList<>());
indexes.get(id).add(index);
}
index++;
}
for (Map.Entry<String, Stream<Integer>> e : indexes.entrySet()) {
List<Options> result = new ArrayList<>();
for (Map.Entry<String, List<Integer>> e : indexes.entrySet()) {
String benchmarkName = e.getKey() + "TraceBenchmark";
Stream<Integer> benchmarkIds = e.getValue();
Stream<Integer> benchmarkIds = e.getValue().stream();
String[] benchmarkIdsStrings = benchmarkIds.map(Object::toString)
.toArray(String[]::new);
int chunkSize = 50;
for (int i = 0; i < benchmarkIdsStrings.length; i += chunkSize) {
// We select a subset of benchmarks to run for this chunk
String[] subset = new String[chunkSize];
for (int j = 0; j < 5; ++j) {
subset[j] = benchmarkIdsStrings[i];
}
Options o = new OptionsBuilder()
.mode(Mode.SingleShotTime)
.resultFormat(ResultFormatType.CSV)
.shouldFailOnError(true)
.measurementTime(new TimeValue(250, TimeUnit.MILLISECONDS))
.warmupTime(new TimeValue(250, TimeUnit.MILLISECONDS))
.result(benchmarkName + ".csv")
.param("traceId", benchmarkIdsStrings)
.param("traceFileName", "serialized-benchmarks")
.include(benchmarkName)
.build();
result.add(o);
}
Options o = new OptionsBuilder()
.mode(Mode.SingleShotTime)
.resultFormat(ResultFormatType.CSV)
.shouldFailOnError(true)
.measurementTime(new TimeValue(250, TimeUnit.MILLISECONDS))
.warmupTime(new TimeValue(250, TimeUnit.MILLISECONDS))
.result(benchmarkName + ".csv")
.param("traceId", benchmarkIdsStrings)
.param("traceFileName", "serialized-benchmarks")
.include(benchmarkName)
.build();
result.add(o);
}
return result;
......
......@@ -24,7 +24,7 @@ public class SetTraceBenchmark {
switch (dataStructureName) {
case "HashSet": collection = new HashSet(); break;
case "TreeSet": collection = new TreeSet(); break;
case "LinkedHashSet": collection = new LinkedHashSet();
case "LinkedHashSet": collection = new LinkedHashSet(); break;
default:
throw new RuntimeException("Invalid: " + dataStructureName);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment