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

Add CSV Exporter

parent 56921efe
No related branches found
No related tags found
4 merge requests!159Re-implementation of Theodolite with Kotlin/Quarkus,!157Update Graal Image in CI pipeline,!105Introduce CSV exporter,!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( ...@@ -25,7 +25,6 @@ class BenchmarkExecutorImpl(
val benchmarkDeployment = benchmark.buildDeployment(load, res, this.configurationOverrides) val benchmarkDeployment = benchmark.buildDeployment(load, res, this.configurationOverrides)
benchmarkDeployment.setup() benchmarkDeployment.setup()
this.waitAndLog() this.waitAndLog()
benchmarkDeployment.teardown()
var result = false var result = false
try { try {
...@@ -46,6 +45,8 @@ class BenchmarkExecutorImpl( ...@@ -46,6 +45,8 @@ class BenchmarkExecutorImpl(
logger.error { "Evaluation failed for resource: ${res.get()} and load: ${load.get()} error: $e" } logger.error { "Evaluation failed for resource: ${res.get()} and load: ${load.get()} error: $e" }
} }
benchmarkDeployment.teardown()
this.results.setResult(Pair(load, res), result) this.results.setResult(Pair(load, res), result)
return 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