JMHProcessor.kt 1.29 KB
Newer Older
1
2
3
4
5
6
7
8
9
package se.lth.cs

import org.apache.commons.csv.CSVFormat
import org.apache.commons.csv.CSVParser
import java.io.File
import java.io.FileReader
import java.io.Reader

class JMHProcessor {
10
    fun processFile(filename: String): List<List<String?>> {
11
12
13
        return processReader(FileReader(File(filename)))
    }

14
    fun processReader(reader: Reader): List<List<String?>> {
15
16
17
18
        var parser = CSVParser(reader, CSVFormat.DEFAULT.withFirstRecordAsHeader())
        // We are grouping the parameters by any parameter excep the data structure name (which we want)

        val columns = parser.headerMap.keys
19
        // These are the columns we want to use for group by
20
21
22
        val selectedColumns = columns
                .filter { it -> it.contains("Param") }
                .minus("Param: datastructureName")
23
                .plus("Benchmark")
24
25
26
27
28
29
30
31
32

        val seedsToRecords = parser.records.groupBy { record ->
            selectedColumns.map { column -> record.get(column) }
        }

        return seedsToRecords.values.map { records ->
            val seed = records[0].get("Param: seed")
            val size = records[0].get("Param: applicationSize")
            val bestScore = records.maxBy { it.get("Score") }
33
            listOf(seed, size, bestScore?.get("Param: datastructureName"))
34
35
36
        }
    }
}