Skip to content
Snippets Groups Projects
Commit c854a1fb authored by Lorenz Boguhn's avatar Lorenz Boguhn
Browse files

Add CSV Exporter

parent 671fe9be
No related branches found
No related tags found
4 merge requests!159Re-implementation of Theodolite with Kotlin/Quarkus,!157Update Graal Image in CI pipeline,!108Feature/185 Make Paths Configurable,!83WIP: Re-implementation of Theodolite with Kotlin/Quarkus
package theodolite.evaluation
import theodolite.util.PrometheusResponse
import java.io.File
import java.io.PrintWriter
class CsvExporter {
/**
* Uses the PrintWriter to transform a PrometheusResponse to Csv
*/
fun toCsv(name : String,prom: PrometheusResponse){
val x = toArray(prom)
val csvOutputFile: File = File(name+".csv")
PrintWriter(csvOutputFile).use { pw ->
pw.println(listOf("name","time","value").joinToString())
x.forEach{
pw.println(it.joinToString())
}
}
}
/**
* Converts a PrometheusResponse into a List of List of Strings
*/
private fun toArray(prom : PrometheusResponse): MutableList<List<String>> {
val name = prom.data?.result?.get(0)?.metric?.group.toString()
val values = prom.data?.result?.get(0)?.values
val dataList = mutableListOf<List<String>>()
if (values != null) {
for (x in values){
val y = x as List<*>
dataList.add(listOf(name,"${y[0]}","${y[1]}"))
}
}
return dataList
}
}
......@@ -25,7 +25,6 @@ class BenchmarkExecutorImpl(
val benchmarkDeployment = benchmark.buildDeployment(load, res, this.configurationOverrides)
benchmarkDeployment.setup()
this.waitAndLog()
benchmarkDeployment.teardown()
var result = false
try {
......@@ -46,6 +45,8 @@ class BenchmarkExecutorImpl(
logger.error { "Evaluation failed for resource: ${res.get()} and load: ${load.get()} error: $e" }
}
benchmarkDeployment.teardown()
this.results.setResult(Pair(load, res), result)
return result
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment