Skip to content

Commit

Permalink
[K/N] Fix crash that occurs when no benchmarks where run
Browse files Browse the repository at this point in the history
  • Loading branch information
qurbonzoda committed Oct 18, 2021
1 parent 880ac11 commit a6fd498
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ internal object TextBenchmarkReportFormatter : BenchmarkReportFormatter() {

override fun format(results: Collection<ReportBenchmarkResult>): String {
fun columnLength(column: String, selector: (ReportBenchmarkResult) -> String): Int =
max(column.length, results.maxOf { selector(it).length })
max(column.length, results.maxOfOrNull { selector(it).length } ?: 0)

val shortNames = denseBenchmarkNames(results.map { it.benchmark.name })
val nameLength = columnLength("Benchmark") { shortNames[it.benchmark.name]!! }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,8 @@ class NativeExecutor(
}

private fun storeResults(benchmarks: List<BenchmarkDescriptor<Any?>>, complete: () -> Unit) {
additionalArguments[0].readFile().lines().forEach {
val resultsContent = additionalArguments[0].readFile()
resultsContent.takeIf(String::isNotEmpty)?.lines()?.forEach {
val (configFileName, samplesList) = it.split(": ")
val samples = samplesList.split(", ").map { it.toDouble() }.toDoubleArray()
val benchmarkRun = configFileName.parseBenchmarkConfig()
Expand Down

0 comments on commit a6fd498

Please sign in to comment.