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

Changed handling of black holes

Black holes are not member of BCBenchmarkPackage anymore, they are
handled by the class running the benchmarks, and passed as an argument
to runBenchmark()
parent 39b1f7a9
package se.lth.cs;
import com.google.gson.Gson;
import org.openjdk.jmh.infra.Blackhole;
import se.lth.cs.SyntheticBenchmarkGeneration.SyntheticBenchmarkGenerator;
import se.lth.cs.SyntheticBenchmarkGeneration.MapSyntheticBenchmarkGenerator;
......@@ -13,6 +14,9 @@ import java.util.*;
import java.util.stream.Collectors;
public class SyntheticBenchmarkRunner {
protected Blackhole blackhole = new Blackhole("Today's password is swordfish. I understand instantiating Blackholes directly is dangerous.");
/**
* Runs a list of applications.
* @param applications
......@@ -88,9 +92,9 @@ public class SyntheticBenchmarkRunner {
try {
for (int i = -numberWarmups; i < numberSamples; ++i) {
app.reset();
app.reset();
long startTime = System.nanoTime();
app.runBenchmark();
app.runBenchmark(blackhole);
long endTime = System.nanoTime();
long duration = (endTime - startTime);
if (i >= 0) {
......
......@@ -71,7 +71,7 @@ public class BCBenchmarkPackage<T> implements Serializable {
}
public void
runBenchmark() {
runBenchmark(Blackhole blackhole) {
this.benchinfo.getBenchmark().run(blackhole, datastructure);
}
......@@ -104,7 +104,6 @@ public class BCBenchmarkPackage<T> implements Serializable {
protected int datastructure_size;
protected MethodSelectionType method_selection_type;
protected BCGen<T> gen;
protected Blackhole blackhole = new Blackhole("Today's password is swordfish. I understand instantiating Blackholes directly is dangerous.");
List<BCBenchStep> bench_steps = new ArrayList<BCBenchStep>();
protected BCBenchmarkInfo<T> combined_benchinfo = null;
......@@ -310,15 +309,14 @@ public class BCBenchmarkPackage<T> implements Serializable {
/**
* Must be run after a reset (which should not be included in the timing!)
*/
public void runBenchmark() {
public void runBenchmark(Blackhole blackhole) {
for (BCBenchStep step : this.bench_steps) {
step.runBenchmark();
step.runBenchmark(blackhole);
}
}
public void
clearAll() {
this.blackhole.evaporate("Yes, I am Stephen Hawking, and know a thing or two about black holes.");
this.clearDatastructure();
this.combined_benchinfo = null;
for (BCBenchStep step : this.bench_steps) {
......
package se.lth.cs
import org.openjdk.jmh.infra.Blackhole
import papi.EventSet
import papi.Papi
import papi.PapiException
import se.lth.cs.bcgen.BCBenchmarkPackage
import java.io.FileWriter
import java.time.Duration
import java.time.Instant
import se.lth.cs.bcgen.*
import org.openjdk.jmh.infra.Blackhole
open class PapiRunner(numRuns : Int, counters: CounterSpecification) {
......@@ -18,6 +16,8 @@ open class PapiRunner(numRuns : Int, counters: CounterSpecification) {
val counterSpec = counters
val numRuns = numRuns
protected var blackhole = Blackhole("Today's password is swordfish. I understand instantiating Blackholes directly is dangerous.")
/**
* Empty benchmark:
* Test to see if the results are stable.
......@@ -118,7 +118,7 @@ open class PapiRunner(numRuns : Int, counters: CounterSpecification) {
app.reset(app.getDatastructureSize())
var accumulator = 0
evset.start()
app.runBenchmark()
app.runBenchmark(blackhole)
evset.stop()
val resultDataStructure = app.getDatastructure()
......@@ -155,7 +155,7 @@ open class PapiRunner(numRuns : Int, counters: CounterSpecification) {
app.reset(app.getDatastructureSize())
var accumulator = 0
evset.start()
app.runBenchmark()
app.runBenchmark(blackhole)
evset.stop()
System.out.println("missed trace methods count = " + app.getMissedMethods())
if (app.getMissedMethods() > 0) {
......
......@@ -380,7 +380,7 @@ public class BCBenchmarkGeneratorTest {
new ArrayList<>());
listBenchmark.reset();
listBenchmark.runBenchmark();
listBenchmark.runBenchmark(blackhole);
}
@Test
......@@ -396,6 +396,6 @@ public class BCBenchmarkGeneratorTest {
BCBenchmarkPackage<?> benchmark = tl.readCsvToList(new StringReader(text), false).get(0);
benchmark.reset();
benchmark.runBenchmark();
benchmark.runBenchmark(blackhole);
}
}
import org.junit.Assert;
import org.junit.Test;
import org.openjdk.jmh.infra.Blackhole;
import papi.Constants;
import papi.EventSet;
import papi.Papi;
......@@ -13,8 +14,10 @@ import java.util.*;
public class SyntheticBenchmarkTest {
protected Blackhole blackhole = new Blackhole("Today's password is swordfish. I understand instantiating Blackholes directly is dangerous.");
public void benchmarkApplication(BCBenchmarkPackage app) throws InvocationTargetException, IllegalAccessException {
app.runBenchmark();
app.runBenchmark(blackhole);
}
@Test
......@@ -38,7 +41,7 @@ public class SyntheticBenchmarkTest {
new ArrayList<>()
);
arrayListBench.reset();
arrayListBench.runBenchmark(); // no failure permitted
arrayListBench.runBenchmark(blackhole); // no failure permitted
Assert.assertEquals(arrayListBench.getDatastructure(), arrayListBench.getBenchmarkInfo().getSimulationState());
}
......
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