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

Made JMHProcessor record base structure size too

The base structure size can be useful when processing the JMH results
parent 9ec71637
......@@ -13,35 +13,41 @@ class JMHProcessor {
return process(FileReader(file))
}
data class JMHRecord(val seed : Int, val size : Int, val collection : String, val best : String) {
data class JMHRecord(val seed : Int, val size : Int, val baseStructureSize : Int, val collection : String, val datastructure : String, val best : String) {
fun toList() : List<String> {
return listOf(collection, seed.toString(), size.toString(), best)
return listOf(collection, seed.toString(), size.toString() , baseStructureSize.toString(), datastructure, best)
}
}
private val selectedColumns = listOf(
"Benchmark",
"Param: seed",
"Param: applicationSize",
"Param: baseStructureSize"
)
fun process(reader : Reader): List<JMHRecord> {
var parser = CSVParser(reader, CSVFormat.DEFAULT.withFirstRecordAsHeader())
// We are grouping the parameters by any parameter except the data structure name (which we want)
val selectedColumns = listOf(
"Benchmark",
"Param: seed",
"Param: applicationSize"
)
// We group the records by our selected columns
val seedsToRecords = parser.records.groupBy { record ->
selectedColumns.map { column -> record.get(column) }
}
return seedsToRecords.values.map { records ->
return seedsToRecords.values.flatMap { records ->
val interfaceName = records[0].get("Benchmark").let { processBenchmarkName(it) }
val seed = records[0].get("Param: seed")
.let { Integer.parseInt(it)}
val size = records[0].get("Param: applicationSize")
.let { Integer.parseInt(it)}
val baseStructureSize = records[0].get("Param: baseStructureSize")
.let { Integer.parseInt(it)}
val best = getBestDataStructure(records)
JMHRecord(seed, size, interfaceName, best!!)
records.map{
JMHRecord(seed, size, baseStructureSize, interfaceName, it.get("Param: datastructureName"), best!!)
}
}
}
......@@ -51,11 +57,7 @@ class JMHProcessor {
// - same seed
// - same benchmark (List, Map, etc)
// - same application size
val selectedColumns = listOf<String>(
"Benchmark",
"Param: seed",
"Param: applicationSize"
)
// - same base structure size
assert(records.all { record ->
selectedColumns.map{ record.get(it)} ==
selectedColumns.map{ records[0].get(it)}})
......@@ -91,7 +93,7 @@ class JMHProcessor {
*/
fun print(writer : Writer, records : List<JMHRecord>) {
val printer = CSVPrinter(writer, CSVFormat.DEFAULT.withFirstRecordAsHeader())
printer.printRecord("Interface", "Seed", "Size", "Best")
printer.printRecord("Interface", "Seed", "Size", "BaseStructureSize", "Best")
for (record in records) {
printer.printRecord(record.toList())
}
......
......@@ -62,7 +62,7 @@ class JMHProcessorTest {
val result = processor!!.process(reader)
Assert.assertEquals(
listOf(
JMHProcessor.JMHRecord(0, 10, "List", "LinkedList")
JMHProcessor.JMHRecord(0, 10, 0, "List", "LinkedList", "LinkedList")
)
, result
)
......@@ -106,7 +106,8 @@ class JMHProcessorTest {
val result = processor!!.process(reader)
Assert.assertEquals(
listOf(
JMHProcessor.JMHRecord(0, 10, "List", "ArrayList")
JMHProcessor.JMHRecord(0, 10, 0, "List", "LinkedList", "ArrayList"),
JMHProcessor.JMHRecord(0, 10, 0, "List", "ArrayList", "ArrayList")
),
result
)
......@@ -150,8 +151,23 @@ class JMHProcessorTest {
val result = processor!!.process(reader)
Assert.assertEquals(
listOf(
JMHProcessor.JMHRecord(0, 10, "List", "LinkedList"),
JMHProcessor.JMHRecord(0, 10, "Map", "HashMap")
JMHProcessor.JMHRecord(0, 10, 0, "List", "LinkedList", "LinkedList"),
JMHProcessor.JMHRecord(0, 10, 0, "Map", "HashMap", "HashMap")
),
result
)
}
@Test
fun testDifferentBaseSize() {
val data = generateData()
val reader = StringReader(data)
val result = processor!!.process(reader)
Assert.assertEquals(
listOf(
JMHProcessor.JMHRecord(0, 10,0, "List", "LinkedList", "ArrayList"),
JMHProcessor.JMHRecord(0, 10, 0, "List", "ArrayList", "ArrayList"),
JMHProcessor.JMHRecord(0, 10, 10, "List", "ArrayList", "ArrayList")
),
result
)
......@@ -209,6 +225,7 @@ class JMHProcessorTest {
Assert.assertTrue(interfaces.contains(record.get("Interface")))
Assert.assertTrue(numberRegex.matches(record.get("Seed")))
Assert.assertTrue(numberRegex.matches(record.get("Size")))
Assert.assertTrue(numberRegex.matches(record.get("BaseStructureSize")))
Assert.assertTrue(interfaces.any { record.get("Best").contains(it) })
}
}
......@@ -247,8 +264,23 @@ class JMHProcessorTest {
"ArrayList",
0
).joinToString(",")
var row3 =
listOf(
"\"se.lth.cs.jmh.ListApplicationBenchmark.ListApplicationBenchmark\"",
"\"thrpt\"",
1,
10,
414.886418,
200.555845,
"ops/s",
10,
10,
"ArrayList",
0
).joinToString(",")
data.add(row1)
data.add(row2)
data.add(row3)
val text = "${JMHProcessor.getExpectedHeader()}\n${data.joinToString("\n")}"
return text
}
......
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