Skip to content

Commit a6ea37a

Browse files
committed
Support generator
1 parent ad4885b commit a6ea37a

File tree

1 file changed

+29
-6
lines changed

1 file changed

+29
-6
lines changed

.teamcity/generateChartsByCsv.kts

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,46 @@
11
import java.io.File
2+
import kotlin.sequences.flatMap
23
import kotlin.system.exitProcess
34

45
fun exit() {
56
println("arg1 is folder with csv's")
67
exitProcess(1)
78
}
89

10+
fun parseCsv(csvFile: File): List<Pair<String, Double>> {
11+
return csvFile.readLines()
12+
.filterNot { it.startsWith("\"Benchmark\"") }
13+
.map { it.split(",") }
14+
.map { it[0] to it[4].toDouble() }
15+
}
16+
17+
fun parseJson(jsonFile: File): List<Pair<String, Double>> {
18+
val singleLineJson = jsonFile.readText().replace("\n", "")
19+
20+
val benchmarks = Regex(".+?(\"benchmark\".+?scoreError)+.+?").findAll(singleLineJson).map { it.groupValues[1] }.toList()
21+
22+
val benchmarkRegex = Regex("\"benchmark\"\\s:\\s(\".+?\").+?\"score\":\\s(.+?),.+")
23+
val benchmarkValues = benchmarks.map {
24+
benchmarkRegex.find(it)!!.groupValues
25+
}
26+
27+
return benchmarkValues.map {
28+
it[1] to it[2].toDouble()
29+
}
30+
}
31+
32+
933
fun main(args: Array<String>) {
1034
if (args.isEmpty()) exit()
1135
val directory = File(args[0])
1236
if (!directory.exists()) exit()
1337

14-
directory
38+
val values = directory
1539
.walk()
16-
.filter { it.extension == "csv" }
17-
.flatMap { it.readLines() }
18-
.filterNot { it.startsWith("\"Benchmark\"") }
19-
.map { it.split(",") }
20-
.map { it[0] to it[4].toDouble() }
40+
.filter { it.extension == "json" } //csv
41+
.flatMap { file -> parseJson(file) } //parseCsv
42+
43+
values
2144
.groupBy({ it.first}, { it.second })
2245
.map { it.key to (it.value.minOf { x -> x } to it.value.maxOf { x -> x })}
2346
.forEach {

0 commit comments

Comments
 (0)