Skip to content

Commit

Permalink
Fixed benchmark printing (#877)
Browse files Browse the repository at this point in the history
  • Loading branch information
oxisto committed Sep 1, 2022
1 parent 015454c commit bbc1ec5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public class TranslationResult extends Node implements StatisticsHolder {
*/
private final Set<Node> additionalNodes = new HashSet<>();

private final List<MeasurementHolder> benchmarks = new ArrayList<>();
private final Set<MeasurementHolder> benchmarks = new LinkedHashSet<>();

public TranslationResult(TranslationManager translationManager) {
this.translationManager = translationManager;
Expand Down Expand Up @@ -171,7 +171,7 @@ public void addBenchmark(@NotNull MeasurementHolder b) {
}

@NotNull
public List<MeasurementHolder> getBenchmarks() {
public Set<MeasurementHolder> getBenchmarks() {
return benchmarks;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,24 +55,30 @@ class BenchmarkResults(val entries: List<List<Any>>) {
/** Interface definition to hold different statistics about the translation process. */
interface StatisticsHolder {
val translatedFiles: List<String>
val benchmarks: List<MeasurementHolder>
val benchmarks: Set<MeasurementHolder>
val config: TranslationConfiguration

fun addBenchmark(b: MeasurementHolder)

val benchmarkResults: BenchmarkResults
get() {
return BenchmarkResults(
listOf(
val results =
mutableListOf(
listOf("Translation config", config),
listOf("Number of files translated", translatedFiles.size),
listOf(
"Translated file(s)",
translatedFiles.map { relativeOrAbsolute(Path.of(it), config.topLevel) }
),
*benchmarks.map { it.benchmarkedValues }.toTypedArray()
)
)

benchmarks.forEach {
it.measurements.forEach { measurement ->
results += listOf(measurement.key, measurement.value)
}
}

return BenchmarkResults(results)
}
}

Expand Down Expand Up @@ -212,7 +218,7 @@ constructor(
): Any? {
if (measurementKey == null || measurementValue == null) return null

measurements["Measured $measurementKey"] = measurementValue
measurements["Measurement: $measurementKey"] = measurementValue
logDebugMsg("$caller $measurementKey: result is $measurementValue")

// update our holder, if we have any
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class StatisticsCollectionPass : Pass() {

val nodeMeasurement =
MeasurementHolder(this.javaClass, "Measuring Nodes", false, translationResult)
nodeMeasurement.addMeasurement("Graph nodes", nodes.toString())
nodeMeasurement.addMeasurement("Total graph nodes", nodes.toString())
nodeMeasurement.addMeasurement("Problem nodes", problemNodes.toString())
}

Expand Down

0 comments on commit bbc1ec5

Please sign in to comment.