Commit 5fdbd542 authored by Noric Couderc's avatar Noric Couderc
Browse files

Refactoring: Extracted method to get application from JMHRecord.

Getting JMH record's application was in the PapiRunner class, the method is
extreacted to become a method of JMHRecord.
parent 89762615
......@@ -17,6 +17,31 @@ class JMHProcessor {
fun toList() : List<String> {
return listOf(collection, seed.toString(), size.toString() , baseStructureSize.toString(), datastructure, best)
}
fun generateApplication() : Application<*>? {
var application : Application<*>? = null
val dataStructure = getClassFromSimpleName(datastructure)
if (collection == "List") {
application = ListApplication(seed, size, dataStructure as MutableList<Int>?)
return application
}
if (collection == "Map") {
application = MapApplication(seed, size, dataStructure as MutableMap<Int, Int>?)
return application
}
if (collection == "Set") {
application = SetApplication(seed, size, dataStructure as MutableSet<Int>?)
return application
}
return null
}
private fun getClassFromSimpleName(name : String) : Any {
val className = "java.util.$name"
return Class.forName(className).getConstructor().newInstance()
}
}
private val selectedColumns = listOf(
......
......@@ -230,7 +230,7 @@ open class PapiRunner(counters: CounterSpecification) {
}
fun processJMHData(numRuns: Int, jmhData: List<JMHProcessor.JMHRecord>): List<FeatureVector> {
val applications = jmhData.map { processJMHRecord(it)!! }
val applications = jmhData.map { it.generateApplication()!! }
val bests = jmhData.map { it.best }
val appsBest = applications.zip(bests)
......@@ -245,29 +245,4 @@ open class PapiRunner(counters: CounterSpecification) {
FeatureVector(app.seedString, app.dataStructureName, best, aggregates)
}
}
private fun getClassFromSimpleName(name : String) : Any {
val className = "java.util.$name"
return Class.forName(className).getConstructor().newInstance()
}
private fun processJMHRecord(record : JMHProcessor.JMHRecord) : Application<*>? {
var application : Application<*>? = null
val dataStructure = getClassFromSimpleName(record.datastructure)
if (record.collection == "List") {
application = ListApplication(record.seed, record.size, dataStructure as MutableList<Int>?)
return application
}
if (record.collection == "Map") {
application = MapApplication(record.seed, record.size, dataStructure as MutableMap<Int, Int>?)
return application
}
if (record.collection == "Set") {
application = SetApplication(record.seed, record.size, dataStructure as MutableSet<Int>?)
return application
}
return null
}
}
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