Commit 9a14d747 authored by Noric Couderc's avatar Noric Couderc
Browse files

Added test for perf of benchmarking

We check the time spent to run benchmarks doesn't increase with the
number of iterations.
parent e97747d7
import com.google.common.graph.GraphBuilder import com.google.common.graph.GraphBuilder
import com.google.common.graph.MutableGraph import com.google.common.graph.MutableGraph
import org.apache.commons.math3.stat.regression.SimpleRegression
import org.junit.jupiter.api.* import org.junit.jupiter.api.*
import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.ParameterizedTest
import org.junit.jupiter.params.provider.ValueSource import org.junit.jupiter.params.provider.ValueSource
import org.openjdk.jmh.infra.Blackhole import org.openjdk.jmh.infra.Blackhole
import papi.Constants import papi.Constants
import papi.EventSet import papi.EventSet
import se.lth.cs.average
import se.lth.cs.bcgen.BCBenchmarkPackage import se.lth.cs.bcgen.BCBenchmarkPackage
import se.lth.cs.papicounters.PAPICounter import se.lth.cs.papicounters.PAPICounter
import se.lth.cs.papicounters.PapiBenchmarkAnalyzer import se.lth.cs.papicounters.PapiBenchmarkAnalyzer
import se.lth.cs.papicounters.PapiTracerRunner import se.lth.cs.papicounters.PapiTracerRunner
import se.lth.cs.smartmodules.tracer.Tracer import se.lth.cs.smartmodules.tracer.Tracer
import se.lth.cs.timing.OperationType import se.lth.cs.timing.OperationType
import se.lth.cs.variance
import se.lth.util.ArrayListTracer import se.lth.util.ArrayListTracer
import java.io.ByteArrayOutputStream import java.io.ByteArrayOutputStream
import java.io.File import java.io.File
import java.io.PrintStream import java.io.PrintStream
import kotlin.system.measureTimeMillis
class TracingCollectionRunnerTest { class TracingCollectionRunnerTest {
// In this file, we will test running benchmarks with tracing collections // In this file, we will test running benchmarks with tracing collections
...@@ -205,4 +209,31 @@ class TracingCollectionRunnerTest { ...@@ -205,4 +209,31 @@ class TracingCollectionRunnerTest {
Assertions.assertEquals(1, r.benchmark.numberRuns) Assertions.assertEquals(1, r.benchmark.numberRuns)
} }
} }
@Test
fun testPerformance() {
// TODO: Do the same, but create a lot of benchmarks!
val bench = BCBenchmarkPackage.LIST(12345, 1000, 0, ArrayList<Int>())
val features = listOf(PAPICounter("PAPI_TOT_CYC"), PAPICounter("PAPI_TOT_INS"))
val times = mutableListOf<Double>()
val max = 100
for (i in 0..max) {
val timeSpent = measureTimeMillis {
runner!!.runIterations(
PapiBenchmarkAnalyzer.RunSpec(10, features, EventSet.create(), bench)
)
}
times.add(timeSpent / 1000.0)
}
val reg = SimpleRegression()
for (i in 0..max) {
reg.addData(i.toDouble(), times[i])
}
Assertions.assertEquals(0.0, reg.slope, 0.01)
}
} }
\ No newline at end of file
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