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

Added toList() to JMHRecord

Makes printing of JMH records to CSV files easier
parent 58042027
......@@ -12,7 +12,11 @@ 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 collection : String, val best : String) {
fun toList() : List<String> {
return listOf(collection, seed.toString(), size.toString(), best)
}
}
fun process(reader : Reader): List<JMHRecord> {
var parser = CSVParser(reader, CSVFormat.DEFAULT.withFirstRecordAsHeader())
......@@ -68,7 +72,7 @@ class JMHProcessor {
val printer = CSVPrinter(writer, CSVFormat.DEFAULT.withFirstRecordAsHeader())
printer.printRecord("Interface", "Seed", "Size", "Best")
for (record in records) {
printer.printRecord(record)
printer.printRecord(record.toList())
}
writer.close()
}
......
......@@ -150,8 +150,8 @@ class JMHProcessorTest {
val result = processor!!.process(reader)
Assert.assertEquals(
listOf(
listOf("List", "0", "10", "LinkedList"),
listOf("Map", "0", "10", "HashMap")
JMHProcessor.JMHRecord(0, 10, "List", "LinkedList"),
JMHProcessor.JMHRecord(0, 10, "Map", "HashMap")
),
result
)
......
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