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

Implemented selecting best data structure by worst case run time

The best data structure with the higher lowest bound of confidence interval for
the running time. So we select the "best" as "best of the worst".
parent e1fd79d4
......@@ -51,6 +51,13 @@ class JMHProcessor {
}
}
/**
* Get the "worst" running time for a JMH benchmark record
*/
private fun getWorstScore(record : CSVRecord): Double {
return record.get("Score").toDouble() - record.get("Score Error (99.9%)").toDouble()
}
private fun getBestDataStructure(records : List<CSVRecord>): String? {
// Precondition
// All records must have
......@@ -66,7 +73,9 @@ class JMHProcessor {
// Map from benchmark base structure size to record with maximum score
val bestRecords = recordsByBaseSize
.mapValues { (k, v) -> v.maxBy { it.get("Score") }}
.mapValues { (k, v) -> v.maxBy {
getWorstScore(it)
}}
// We count the number of times the data structure has won
// (Computing a histogram of the data structure names)
......
......@@ -113,6 +113,51 @@ class JMHProcessorTest {
)
}
@Test
fun testWorstCase() {
var data = mutableListOf<String>()
var row1 =
listOf(
"\"se.lth.cs.jmh.ListApplicationBenchmark.ListApplicationBenchmark\"",
"\"thrpt\"",
1,
10,
185.524701,
29.416447,
"ops/s",
10,
0,
"LinkedList",
0
).joinToString(",")
var row2 =
listOf(
"\"se.lth.cs.jmh.ListApplicationBenchmark.ListApplicationBenchmark\"",
"\"thrpt\"",
1,
10,
185.886418, // Same mean as row 1
100.555845, // Much higher variance (Shouldn't be selected!)
"ops/s",
10,
0,
"ArrayList",
0
).joinToString(",")
data.add(row1)
data.add(row2)
val text = "$header\n${data.joinToString("\n")}"
val reader = StringReader(text)
val result = processor!!.process(reader)
Assert.assertEquals(
listOf(
JMHProcessor.JMHRecord(0, 10, 0, "List", "LinkedList", "LinkedList"),
JMHProcessor.JMHRecord(0, 10, 0, "List", "ArrayList", "LinkedList")
),
result
)
}
@Test
fun testDifferentInterface() {
var data = mutableListOf<String>()
......
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