From fca0b7fedd6f936cbdd4110ee4293efd681a72ba Mon Sep 17 00:00:00 2001 From: vldf Date: Wed, 22 Jul 2020 13:28:15 +0300 Subject: [PATCH] [FIR] Add CFA benchmark --- benchmarks/build.gradle.kts | 1 + .../ControlFlowAnalysisBenchmark.kt | 35 +++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 benchmarks/src/org/jetbrains/kotlin/benchmarks/ControlFlowAnalysisBenchmark.kt diff --git a/benchmarks/build.gradle.kts b/benchmarks/build.gradle.kts index df09953a26e..92d2403a0a6 100644 --- a/benchmarks/build.gradle.kts +++ b/benchmarks/build.gradle.kts @@ -74,6 +74,7 @@ benchmark { param("size", 1000) include("CommonCallsBenchmark") + //include("ControlFlowAnalysisBenchmark") //include("InferenceBaselineCallsBenchmark") } diff --git a/benchmarks/src/org/jetbrains/kotlin/benchmarks/ControlFlowAnalysisBenchmark.kt b/benchmarks/src/org/jetbrains/kotlin/benchmarks/ControlFlowAnalysisBenchmark.kt new file mode 100644 index 00000000000..db4ec1a4bb9 --- /dev/null +++ b/benchmarks/src/org/jetbrains/kotlin/benchmarks/ControlFlowAnalysisBenchmark.kt @@ -0,0 +1,35 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.benchmarks + +import org.openjdk.jmh.annotations.* +import org.openjdk.jmh.infra.Blackhole +import java.util.concurrent.TimeUnit + +@BenchmarkMode(Mode.AverageTime) +@OutputTimeUnit(TimeUnit.MILLISECONDS) +@State(Scope.Benchmark) +open class ControlFlowAnalysisBenchmark : AbstractSimpleFileBenchmark() { + @Param("1000") + private var size: Int = 0 + + @Benchmark + fun benchmark(bh: Blackhole) { + analyzeGreenFile(bh) + } + + override fun buildText() = + buildString { + appendLine("fun test() {") + for (i in 0 until size) { + appendLine("for (i$i in 0..10) { ") + } + for (i in 0 until size) { + appendLine("}") + } + appendLine("}") + } +} \ No newline at end of file