Commit be40d429 authored by Noric Couderc's avatar Noric Couderc
Browse files

Changed printing of errors in case of invalid trace

If the trace contains methods that are not eligible or methods
that are not recognized, it's the benchmark that's reported instead
of have one report for every method
parent 3a34fb27
......@@ -103,6 +103,13 @@ public class SyntheticBenchmarkRunner {
public List<Double> runApplication(BCBenchmarkPackage app) {
ArrayList<Double> durations = new ArrayList();
if (app.getMissedMethods() > 0) {
System.err.println("[XWARN:SIMMISS]: missed "
+ app.getMissedMethods()
+ " out of "
+ app.getTrace().size() + " trace methods");
}
try {
for (int i = -numberWarmups; i < numberSamples; ++i) {
app.reset();
......
......@@ -36,13 +36,15 @@ public class TraceMethodSelectionStrategy extends MethodSelectionStrategy implem
trace_index++;
final Integer method_index = table.findMethod(method_name);
if (method_index == null) {
System.out.println("[XWARN:UMETHOD] Encountered unknown method: '" + method_name + "'");
this.misses++;
return SKIP;
// throw new IllegalStateException("[XWARN:UMETHOD] Encountered unknown method: '" + method_name + "'");
}
if (!table.isEligible(method_index)) {
++this.misses;
this.misses++;
return SKIP;
// throw new IllegalStateException("[XWARN:UMETHOD] Encountered uneligible method: '" + method_name + "'");
}
return method_index;
......
......@@ -157,10 +157,13 @@ open class PapiRunner(numRuns : Int, counters: CounterSpecification) {
evset.start()
app.runBenchmark(blackhole)
evset.stop()
System.out.println("missed trace methods count = " + app.getMissedMethods())
if (app.getMissedMethods() > 0) {
System.out.println("[XWARN:SIMMISS]: missed " + Integer.toString(app.getMissedMethods()) + " out of " + Integer.toString(app.getTrace().size) + " trace methods")
}
System.out.println("missed trace methods count = " + app.getMissedMethods())
if (app.getMissedMethods() > 0) {
System.out.println("[XWARN:SIMMISS]: missed "
+ Integer.toString(app.getMissedMethods())
+ " out of "
+ Integer.toString(app.getTrace().size) + " trace methods")
}
val resultDataStructure = app.getDatastructure()
// We reset the benchmark
......
......@@ -142,16 +142,17 @@ class TraceLoader {
kvp.key.left,
Integer.parseInt(kvp.key.right))
try {
val app = generateSyntheticBenchmark(
traceKey,
InterfaceName.fromCollectionType(target_type),
kvp.value.map { it["method"] },
initClass!!)
app.reset()
val app = generateSyntheticBenchmark(
traceKey,
InterfaceName.fromCollectionType(target_type),
kvp.value.map { it["method"] },
initClass!!)
app.reset()
if (app.missedMethods > 0.1 * app.traceSize) {
System.err.println("[XWARN] Too many missed methods, skipping benchmark")
} else {
apps.add(app)
} catch (e: IllegalStateException) {
System.err.println("WARNING: Benchmark Invalid, removing it.")
}
} else {
System.err.println(String.format("Class: '%s' is not part of 'java.util'",
......
......@@ -404,4 +404,20 @@ public class BCBenchmarkGeneratorTest {
benchmark.reset();
benchmark.runBenchmark(blackhole);
}
@Test
public void testTraceRemoveFirst() {
// This should not fail but should still print a warning
TraceLoader tl = new TraceLoader();
String text = ",id,target_type,location,method,step\n" +
"1,1,java.util.LinkedList,loc1,boolean add(E),1\n" +
"2,1,java.util.LinkedList,loc1,boolean isEmpty(),2\n" +
// Important: Call to removeFirst
"3,1,java.util.LinkedList,loc1,E removeFirst(),3\n" +
"4,1,java.util.LinkedList,loc1,int size(),4\n" +
"5,1,java.util.LinkedList,loc1,\"void clear()\",5";
List<BCBenchmarkPackage<?>> bcBenchmarkPackages = tl.readCsvToList(new StringReader(text), false);
Assert.assertTrue(bcBenchmarkPackages.isEmpty());
}
}
......@@ -59,18 +59,19 @@ public class SyntheticBenchmarkRunnerTest {
// Same id, different location
"1,1,loc1,java.util.LinkedList,boolean add(E),1\n" +
"2,1,loc1,java.util.LinkedList,boolean add(E),2\n" +
"3,2,loc2,java.util.ArrayList,boolean add(E),1\n" +
"4,2,loc2,java.util.ArrayList,boolean add(E),2\n" +
"5,3,loc3,java.util.HashSet,boolean add(E),1\n" +
"6,3,loc3,java.util.HashSet,boolean add(E),2\n";
"3,1,loc1,java.util.LinkedList,E removeFirst(),3\n" +
"4,2,loc2,java.util.ArrayList,boolean add(E),1\n" +
"5,2,loc2,java.util.ArrayList,boolean add(E),2\n" +
"6,3,loc3,java.util.HashSet,boolean add(E),1\n" +
"7,3,loc3,java.util.HashSet,boolean add(E),2\n";
List<BCBenchmarkPackage<?>> benchmarks = tl.readCsvToList(new StringReader(text), false);
Assert.assertEquals(2, benchmarks.size());
List<TraceLoader.TraceData> traceData = tl.readCsvData(new StringReader(text), false);
Stream<BCBenchmarkPackage<?>> benchmarks = tl.benchmarksFromTraces(
tl.removeDuplicates(traceData)).map(it -> it.component2());
SyntheticBenchmarkRunner runner = new SyntheticBenchmarkRunner();
List<TrainingSetValue> results = runner.runBenchmarks(benchmarks.collect(Collectors.toList()));
Assert.assertEquals(9, results.size());
List<TrainingSetValue> results = runner.runBenchmarks(benchmarks);
Assert.assertEquals(2, results.size());
// All benchmarks that have the same ID must have the same best data structure
for (TrainingSetValue t1 : results) {
// We also want to check there's no benchmark
......
Supports Markdown
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