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

Added type Experiment.Result

This type is the type we'll use for storing the results of an
experiment, instead of just a list of maps.
parent d7ac1c05
......@@ -11,7 +11,11 @@ class Experiment(val numberIterations : Int,
val benchmark : BCBenchmarkPackage<*>,
val features : FeatureSet) : FeatureVisitor {
fun run() : List<Map<Feature, Double>> {
data class Result(val iterationNumber : Int,
val benchmark : BCBenchmarkPackage<*>,
val values : Map<Feature, Double>)
fun run() : List<Result> {
if (features.features.isEmpty()) { return listOf() }
val eventSetBuilder = EventSetBuilder()
......@@ -24,14 +28,17 @@ class Experiment(val numberIterations : Int,
PapiBenchmarkAnalyzer.RunSpec(numberIterations, counters.toList(), evSet, benchmark)
)
var results = mutableListOf<Map<Feature, Double>>()
var iterationNumber = 0
val results = mutableListOf<Result>()
for (i in iterations) {
currentIteration = i
currentIterationResults = mutableMapOf()
// We aggregate all our features for that
// specific iteration!
features.accept(this)
results.add(currentIterationResults.toMap())
val values = currentIterationResults.toMap()
results.add(Result(iterationNumber, benchmark, values))
iterationNumber++
}
return results.toList()
......
......@@ -30,8 +30,12 @@ class ExperimentTest {
val results = exp.run()
Assertions.assertEquals(10, results.size)
Assertions.assertEquals(
IntRange(0, 9).toList(),
results.map { it.iterationNumber }
)
Assertions.assertEquals(setOf(PAPICounter("PAPI_TOT_CYC")),
results.flatMap{ it.keys }.toSet())
results.flatMap{ it.values.keys }.toSet())
}
@Test
......@@ -61,12 +65,12 @@ class ExperimentTest {
val results = exp.run()
for (iteration in results) {
Assertions.assertTrue(iteration.containsKey(PAPICounter("PAPI_TOT_INS")))
Assertions.assertTrue(iteration.containsKey(costPerDelete))
Assertions.assertTrue(iteration.containsKey(costPerDelete.counter))
Assertions.assertTrue(iteration.containsKey(cacheMissRate))
Assertions.assertTrue(iteration.containsKey(cacheMissRate.f1))
Assertions.assertTrue(iteration.containsKey(cacheMissRate.f2))
Assertions.assertTrue(iteration.values.containsKey(PAPICounter("PAPI_TOT_INS")))
Assertions.assertTrue(iteration.values.containsKey(costPerDelete))
Assertions.assertTrue(iteration.values.containsKey(costPerDelete.counter))
Assertions.assertTrue(iteration.values.containsKey(cacheMissRate))
Assertions.assertTrue(iteration.values.containsKey(cacheMissRate.f1))
Assertions.assertTrue(iteration.values.containsKey(cacheMissRate.f2))
}
}
......
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