Initial import of benchmarks from https://github.com/dzharkov/kotlin-compiler-benchmarks
diff --git a/.idea/kotlinScripting.xml b/.idea/kotlinScripting.xml
new file mode 100644
index 0000000..a6fe551
--- /dev/null
+++ b/.idea/kotlinScripting.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="KotlinScriptingSettings">
+    <option name="isAutoReloadEnabled" value="true" />
+  </component>
+</project>
\ No newline at end of file
diff --git a/benchmarks/build.gradle.kts b/benchmarks/build.gradle.kts
new file mode 100644
index 0000000..f32914d
--- /dev/null
+++ b/benchmarks/build.gradle.kts
@@ -0,0 +1,71 @@
+import kotlinx.benchmark.gradle.*
+
+val benchmarks_version = "0.2.0-dev-4"
+buildscript {
+    val benchmarks_version = "0.2.0-dev-4"
+
+    repositories {
+        maven("https://dl.bintray.com/kotlin/kotlinx")
+        maven("https://dl.bintray.com/kotlin/kotlin-dev")
+    }
+    dependencies {
+        classpath("org.jetbrains.kotlinx:kotlinx.benchmark.gradle:$benchmarks_version")
+    }
+}
+
+apply(plugin = "kotlinx.benchmark")
+
+plugins {
+    java
+    kotlin("jvm")
+    id("jps-compatible")
+}
+
+repositories {
+    maven("https://dl.bintray.com/kotlin/kotlinx")
+    maven("https://dl.bintray.com/kotlin/kotlin-dev")
+}
+
+dependencies {
+    compile(kotlinStdlib())
+    compile(project(":compiler:frontend"))
+    compile(project(":compiler:cli"))
+    compile(intellijCoreDep()) { includeJars("intellij-core") }
+    compile(jpsStandalone()) { includeJars("jps-model") }
+    Platform[192].orHigher {
+        compile(intellijPluginDep("java"))
+    }
+    compile(intellijDep()) { includeIntellijCoreJarDependencies(project) }
+    compile("org.jetbrains.kotlinx:kotlinx.benchmark.runtime-jvm:$benchmarks_version")
+}
+
+sourceSets {
+    "main" { projectDefault() }
+}
+
+benchmark {
+    configurations {
+        named("main") {
+            warmups = 10
+            iterations = 10
+            iterationTime = 1
+            iterationTimeUnit = "sec"
+            param("size", 1000)
+        }
+        
+        register("fir") {
+            warmups = 10
+            iterations = 10
+            iterationTime = 1
+            iterationTimeUnit = "sec"
+            param("isIR", true)
+            param("size", 1000)
+
+            include("CommonCallsBenchmark")
+            //include("InferenceBaselineCallsBenchmark")
+        }
+    }
+    targets {
+        register("main")
+    }
+}
\ No newline at end of file
diff --git a/benchmarks/src/org/jetbrains/kotlin/benchmarks/AbstractInferenceBenchmark.kt b/benchmarks/src/org/jetbrains/kotlin/benchmarks/AbstractInferenceBenchmark.kt
new file mode 100644
index 0000000..1a6e2b2
--- /dev/null
+++ b/benchmarks/src/org/jetbrains/kotlin/benchmarks/AbstractInferenceBenchmark.kt
@@ -0,0 +1,19 @@
+/*
+ * Copyright 2010-2019 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.Param
+import org.openjdk.jmh.annotations.Scope
+import org.openjdk.jmh.annotations.State
+
+@State(Scope.Benchmark)
+abstract class AbstractInferenceBenchmark : AbstractSimpleFileBenchmark() {
+    @Param("true", "false")
+    private var useNI: Boolean = false
+
+    override val useNewInference: Boolean
+        get() = useNI
+}
\ No newline at end of file
diff --git a/benchmarks/src/org/jetbrains/kotlin/benchmarks/AbstractSimpleFileBenchmark.kt b/benchmarks/src/org/jetbrains/kotlin/benchmarks/AbstractSimpleFileBenchmark.kt
new file mode 100644
index 0000000..0d666ac
--- /dev/null
+++ b/benchmarks/src/org/jetbrains/kotlin/benchmarks/AbstractSimpleFileBenchmark.kt
@@ -0,0 +1,209 @@
+package org.jetbrains.kotlin.benchmarks
+
+import com.intellij.openapi.Disposable
+import com.intellij.openapi.extensions.Extensions
+import com.intellij.openapi.project.Project
+import com.intellij.openapi.vfs.CharsetToolkit
+import com.intellij.psi.PsiElementFinder
+import com.intellij.psi.PsiFileFactory
+import com.intellij.psi.impl.PsiFileFactoryImpl
+import com.intellij.psi.search.GlobalSearchScope
+import com.intellij.testFramework.LightVirtualFile
+import org.jetbrains.kotlin.analyzer.ModuleInfo
+import org.jetbrains.kotlin.asJava.finder.JavaElementFinder
+import org.jetbrains.kotlin.builtins.jvm.JvmBuiltIns
+import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys
+import org.jetbrains.kotlin.cli.common.messages.MessageCollector
+import org.jetbrains.kotlin.cli.jvm.compiler.*
+import org.jetbrains.kotlin.cli.jvm.config.addJvmClasspathRoot
+import org.jetbrains.kotlin.config.*
+import org.jetbrains.kotlin.context.SimpleGlobalContext
+import org.jetbrains.kotlin.context.withModule
+import org.jetbrains.kotlin.context.withProject
+import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl
+import org.jetbrains.kotlin.diagnostics.Severity
+import org.jetbrains.kotlin.fir.FirSession
+import org.jetbrains.kotlin.fir.builder.RawFirBuilder
+import org.jetbrains.kotlin.fir.java.FirJavaModuleBasedSession
+import org.jetbrains.kotlin.fir.java.FirLibrarySession
+import org.jetbrains.kotlin.fir.java.FirProjectSessionProvider
+import org.jetbrains.kotlin.fir.resolve.FirProvider
+import org.jetbrains.kotlin.fir.resolve.impl.FirProviderImpl
+import org.jetbrains.kotlin.fir.resolve.transformers.FirTotalResolveTransformer
+import org.jetbrains.kotlin.idea.KotlinLanguage
+import org.jetbrains.kotlin.name.Name
+import org.jetbrains.kotlin.platform.TargetPlatform
+import org.jetbrains.kotlin.platform.jvm.JvmPlatforms
+import org.jetbrains.kotlin.psi.KtFile
+import org.jetbrains.kotlin.resolve.PlatformDependentAnalyzerServices
+import org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatformAnalyzerServices
+import org.jetbrains.kotlin.storage.ExceptionTracker
+import org.jetbrains.kotlin.storage.LockBasedStorageManager
+import org.jetbrains.kotlin.storage.StorageManager
+import org.openjdk.jmh.annotations.*
+import org.openjdk.jmh.infra.Blackhole
+import java.io.File
+
+private fun createFile(shortName: String, text: String, project: Project): KtFile {
+    val virtualFile = object : LightVirtualFile(shortName, KotlinLanguage.INSTANCE, text) {
+        override fun getPath(): String {
+            //TODO: patch LightVirtualFile
+            return "/" + name
+        }
+    }
+
+    virtualFile.charset = CharsetToolkit.UTF8_CHARSET
+    val factory = PsiFileFactory.getInstance(project) as PsiFileFactoryImpl
+
+    return factory.trySetupPsiForFile(virtualFile, KotlinLanguage.INSTANCE, true, false) as KtFile
+}
+
+private val JDK_PATH = File("${System.getProperty("java.home")!!}/lib/rt.jar")
+private val RUNTIME_JAR = File(System.getProperty("kotlin.runtime.path") ?: "dist/kotlinc/lib/kotlin-runtime.jar")
+
+private val LANGUAGE_FEATURE_SETTINGS =
+        LanguageVersionSettingsImpl(
+                LanguageVersion.KOTLIN_1_3, ApiVersion.KOTLIN_1_3,
+                specificFeatures = mapOf(LanguageFeature.NewInference to LanguageFeature.State.ENABLED)
+        )
+
+private fun newConfiguration(useNewInference: Boolean): CompilerConfiguration {
+    val configuration = CompilerConfiguration()
+    configuration.put(CommonConfigurationKeys.MODULE_NAME, "benchmark")
+    configuration.put(CLIConfigurationKeys.INTELLIJ_PLUGIN_ROOT, "../idea/resources")
+    configuration.addJvmClasspathRoot(JDK_PATH)
+    configuration.addJvmClasspathRoot(RUNTIME_JAR)
+    configuration.put(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY, MessageCollector.NONE)
+
+    val newInferenceState = if (useNewInference) LanguageFeature.State.ENABLED else LanguageFeature.State.DISABLED
+    configuration.languageVersionSettings = LanguageVersionSettingsImpl(
+            LanguageVersion.KOTLIN_1_3, ApiVersion.KOTLIN_1_3,
+            specificFeatures = mapOf(
+                    LanguageFeature.NewInference to newInferenceState
+            )
+    )
+    return configuration
+}
+
+@State(Scope.Benchmark)
+abstract class AbstractSimpleFileBenchmark {
+
+    private var myDisposable: Disposable = Disposable { }
+    private lateinit var env: KotlinCoreEnvironment
+    private lateinit var file: KtFile
+
+    @Param("true", "false")
+    protected var isIR: Boolean = false
+
+    protected open val useNewInference get() = isIR
+
+    @Setup(Level.Trial)
+    fun setUp() {
+        if (isIR && !useNewInference) error("Invalid configuration")
+        env = KotlinCoreEnvironment.createForTests(
+                myDisposable, 
+                newConfiguration(useNewInference),
+                EnvironmentConfigFiles.JVM_CONFIG_FILES
+        )
+
+        if (isIR) {
+            Extensions.getArea(env.project)
+                    .getExtensionPoint(PsiElementFinder.EP_NAME)
+                    .unregisterExtension(JavaElementFinder::class.java)
+        }
+
+        file = createFile(
+                "test.kt",
+                buildText(),
+                env.project
+        )
+    }
+
+    protected fun analyzeGreenFile(bh: Blackhole) {
+        if (isIR) {
+            analyzeGreenFileIr(bh)
+        } else {
+            analyzeGreenFileFrontend(bh)
+        }
+    }
+
+    private fun analyzeGreenFileFrontend(bh: Blackhole) {
+        val tracker = ExceptionTracker()
+        val storageManager: StorageManager =
+                LockBasedStorageManager.createWithExceptionHandling("benchmarks", tracker)
+
+        val context = SimpleGlobalContext(storageManager, tracker)
+        val module =
+                ModuleDescriptorImpl(
+                        Name.special("<benchmark>"), storageManager,
+                        JvmBuiltIns(storageManager, JvmBuiltIns.Kind.FROM_DEPENDENCIES)
+                )
+        val moduleContext = context.withProject(env.project).withModule(module)
+
+        val result = TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(
+                moduleContext.project,
+                listOf(file),
+                NoScopeRecordCliBindingTrace(),
+                env.configuration,
+                { scope -> JvmPackagePartProvider(LANGUAGE_FEATURE_SETTINGS, scope) }
+        )
+
+        assert(result.bindingContext.diagnostics.none { it.severity == Severity.ERROR })
+
+        bh.consume(result.shouldGenerateCode)
+    }
+
+    private fun analyzeGreenFileIr(bh: Blackhole) {
+        val scope = GlobalSearchScope.filesScope(env.project, listOf(file.virtualFile))
+                .uniteWith(TopDownAnalyzerFacadeForJVM.AllJavaSourcesInProjectScope(env.project))
+        val session = createSession(env, scope)
+        val builder = RawFirBuilder(session, stubMode = false)
+
+        val totalTransformer = FirTotalResolveTransformer()
+        val firFile = builder.buildFirFile(file).also((session.getService(FirProvider::class) as FirProviderImpl)::recordFile)
+
+        for (transformer in totalTransformer.transformers) {
+            transformer.transformFile(firFile, null)
+        }
+
+        bh.consume(firFile.hashCode())
+    }
+
+    protected abstract fun buildText(): String
+}
+
+fun createSession(
+        environment: KotlinCoreEnvironment,
+        sourceScope: GlobalSearchScope,
+        librariesScope: GlobalSearchScope = GlobalSearchScope.notScope(sourceScope)
+): FirSession {
+    val moduleInfo = FirTestModuleInfo()
+    val project = environment.project
+    val provider = FirProjectSessionProvider(project)
+    return FirJavaModuleBasedSession(moduleInfo, provider, sourceScope).also {
+        createSessionForDependencies(provider, moduleInfo, librariesScope, environment)
+    }
+}
+
+private fun createSessionForDependencies(
+        provider: FirProjectSessionProvider,
+        moduleInfo: FirTestModuleInfo,
+        librariesScope: GlobalSearchScope,
+        environment: KotlinCoreEnvironment
+) {
+    val dependenciesInfo = FirTestModuleInfo()
+    moduleInfo.dependencies.add(dependenciesInfo)
+    FirLibrarySession.create(
+            dependenciesInfo, provider, librariesScope, environment.project,
+            environment.createPackagePartProvider(librariesScope)
+    )
+}
+
+class FirTestModuleInfo(
+        override val name: Name = Name.identifier("TestModule"),
+        val dependencies: MutableList<ModuleInfo> = mutableListOf(),
+        override val platform: TargetPlatform = JvmPlatforms.unspecifiedJvmPlatform,
+        override val analyzerServices: PlatformDependentAnalyzerServices = JvmPlatformAnalyzerServices
+) : ModuleInfo {
+    override fun dependencies(): List<ModuleInfo> = dependencies
+}
diff --git a/benchmarks/src/org/jetbrains/kotlin/benchmarks/CommonCallsBenchmark.kt b/benchmarks/src/org/jetbrains/kotlin/benchmarks/CommonCallsBenchmark.kt
new file mode 100644
index 0000000..4c108e0
--- /dev/null
+++ b/benchmarks/src/org/jetbrains/kotlin/benchmarks/CommonCallsBenchmark.kt
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2010-2019 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 CommonCallsBenchmark : AbstractSimpleFileBenchmark(){
+
+    @Param("1", "10", "100", "1000", "3000", "5000", "7000", "10000")
+    private var size: Int = 0
+
+    @Benchmark
+    fun benchmark(bh: Blackhole) {
+        analyzeGreenFile(bh)
+    }
+
+    override fun buildText() =
+            """
+            |fun foo(): Int = 1
+            |
+            |fun bar() {
+            |${(1..size).joinToString("\n") { "    foo()" }}
+            |}
+            """.trimMargin()
+}
\ No newline at end of file
diff --git a/benchmarks/src/org/jetbrains/kotlin/benchmarks/ComplexDataFlowBenchmark.kt b/benchmarks/src/org/jetbrains/kotlin/benchmarks/ComplexDataFlowBenchmark.kt
new file mode 100644
index 0000000..00a64f9
--- /dev/null
+++ b/benchmarks/src/org/jetbrains/kotlin/benchmarks/ComplexDataFlowBenchmark.kt
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2010-2019 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 ComplexDataFlowBenchmark : AbstractSimpleFileBenchmark(){
+
+    @Param("1", "100", "1000", "3000", "5000", "7000", "10000")
+    private var size: Int = 0
+
+    @Benchmark
+    fun benchmark(bh: Blackhole) {
+        analyzeGreenFile(bh)
+    }
+
+    override fun buildText() =
+            """
+            |
+            |fun bar(x: Any?) {
+            |   var y = x
+            |${(1..size).joinToString("\n") {
+                """
+                |if (x is String) {
+                |   y = x
+                |}
+                |y = 1
+                """.trimMargin()
+            }}
+            |}
+            """.trimMargin()
+
+}
+
diff --git a/benchmarks/src/org/jetbrains/kotlin/benchmarks/ControlFlowOperators.kt b/benchmarks/src/org/jetbrains/kotlin/benchmarks/ControlFlowOperators.kt
new file mode 100644
index 0000000..5d26079
--- /dev/null
+++ b/benchmarks/src/org/jetbrains/kotlin/benchmarks/ControlFlowOperators.kt
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2014, Oracle America, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ *  * Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer.
+ *
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ *  * Neither the name of Oracle nor the names of its contributors may be used
+ *    to endorse or promote products derived from this software without
+ *    specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+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 ControlFlowOperators : AbstractSimpleFileBenchmark(){
+
+    @Param("1", "100", "1000", "3000", "5000", "7000", "10000")
+    private var size: Int = 0
+
+    @Benchmark
+    fun benchmark(bh: Blackhole) {
+        analyzeGreenFile(bh)
+    }
+
+    override fun buildText() =
+            """
+            |var isTrue = true
+            |var s = ""
+            |fun bar() {
+            |${(1..size).joinToString("\n") {
+                """
+                |var x$it: String
+                |
+                |when (s) {
+                |   "A" -> { x$it = "1" }
+                |   "B" -> { x$it = "2" }
+                |   else -> { x$it = "3" }
+                |}
+                |
+                |while (isTrue) {
+                |   x$it.hashCode()
+                |}
+                """.trimMargin()
+            }}
+            |}
+            """.trimMargin()
+}
diff --git a/benchmarks/src/org/jetbrains/kotlin/benchmarks/InferenceBaselineCallsBenchmark.kt b/benchmarks/src/org/jetbrains/kotlin/benchmarks/InferenceBaselineCallsBenchmark.kt
new file mode 100644
index 0000000..c5c60f9
--- /dev/null
+++ b/benchmarks/src/org/jetbrains/kotlin/benchmarks/InferenceBaselineCallsBenchmark.kt
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2010-2019 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 InferenceBaselineCallsBenchmark : AbstractSimpleFileBenchmark() {
+
+    @Param("1", "10", "100", "1000", "5000", "10000")
+    private var size: Int = 0
+
+    @Benchmark
+    fun benchmark(bh: Blackhole) {
+        analyzeGreenFile(bh)
+    }
+
+    override fun buildText() =
+            """
+            |fun foo(x: Int): Int = 1
+            |fun expectsInt(x: Int) {}
+            |fun bar(v: Int) {
+            |${(1..size).map { "    expectsInt(foo(v))" }.joinToString("\n")}
+            |}
+            """.trimMargin()
+}
\ No newline at end of file
diff --git a/benchmarks/src/org/jetbrains/kotlin/benchmarks/InferenceExplicitArgumentsCallsBenchmark.kt b/benchmarks/src/org/jetbrains/kotlin/benchmarks/InferenceExplicitArgumentsCallsBenchmark.kt
new file mode 100644
index 0000000..472d6e8
--- /dev/null
+++ b/benchmarks/src/org/jetbrains/kotlin/benchmarks/InferenceExplicitArgumentsCallsBenchmark.kt
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2010-2019 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 InferenceExplicitArgumentsCallsBenchmark : AbstractInferenceBenchmark() {
+
+    @Param("1", "10", "100", "1000", "5000", "10000")
+    private var size: Int = 0
+
+    @Benchmark
+    fun benchmark(bh: Blackhole) {
+        analyzeGreenFile(bh)
+    }
+
+    override fun buildText() =
+            """
+            |fun <T> foo(x: T): Int = 1
+            |fun expectsInt(x: Int) {}
+            |fun bar(v: Int) {
+            |${(1..size).map { "    expectsInt(foo<Int>(v))" }.joinToString("\n")}
+            |}
+            """.trimMargin()
+}
\ No newline at end of file
diff --git a/benchmarks/src/org/jetbrains/kotlin/benchmarks/InferenceForInApplicableCandidate.kt b/benchmarks/src/org/jetbrains/kotlin/benchmarks/InferenceForInApplicableCandidate.kt
new file mode 100644
index 0000000..ec3bdeb
--- /dev/null
+++ b/benchmarks/src/org/jetbrains/kotlin/benchmarks/InferenceForInApplicableCandidate.kt
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2010-2019 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 InferenceForInApplicableCandidate : AbstractInferenceBenchmark() {
+
+    @Param("1", "10", "100", "1000", "5000", "10000")
+    private var size: Int = 1
+
+    @Benchmark
+    fun benchmark(bh: Blackhole) {
+        analyzeGreenFile(bh)
+    }
+
+    override fun buildText() =
+            """
+            |fun <T : Comparable<T>> foo(x: MutableList<T>) {}
+            |fun <T> foo(x: MutableList<T>, y: (T, T) -> Int) {}
+            |fun bar(x: MutableList<Any>) {
+            |${(1..size).joinToString("\n") { "    foo(x) { a, b -> 1 }" }}
+            |}
+            """.trimMargin()
+}
diff --git a/benchmarks/src/org/jetbrains/kotlin/benchmarks/InferenceFromArgumentCallsBenchmark.kt b/benchmarks/src/org/jetbrains/kotlin/benchmarks/InferenceFromArgumentCallsBenchmark.kt
new file mode 100644
index 0000000..02efd0b
--- /dev/null
+++ b/benchmarks/src/org/jetbrains/kotlin/benchmarks/InferenceFromArgumentCallsBenchmark.kt
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2010-2019 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 InferenceFromArgumentCallsBenchmark : AbstractInferenceBenchmark() {
+
+    @Param("1", "10", "100", "1000", "5000", "10000")
+    private var size: Int = 0
+
+    @Benchmark
+    fun benchmark(bh: Blackhole) {
+        analyzeGreenFile(bh)
+    }
+
+    override fun buildText() =
+            """
+            |fun <T> foo(x: T): Int = 1
+            |fun expectsInt(x: Int) {}
+            |fun bar(v: Int) {
+            |${(1..size).map { "    expectsInt(foo(v))" }.joinToString("\n")}
+            |}
+            """.trimMargin()
+}
\ No newline at end of file
diff --git a/benchmarks/src/org/jetbrains/kotlin/benchmarks/InferenceFromReturnTypeCallsBenchmark.kt b/benchmarks/src/org/jetbrains/kotlin/benchmarks/InferenceFromReturnTypeCallsBenchmark.kt
new file mode 100644
index 0000000..3b2660a
--- /dev/null
+++ b/benchmarks/src/org/jetbrains/kotlin/benchmarks/InferenceFromReturnTypeCallsBenchmark.kt
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2010-2019 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 InferenceFromReturnTypeCallsBenchmark : AbstractInferenceBenchmark() {
+
+    @Param("1", "10", "100", "1000", "5000", "10000")
+    private var size: Int = 0
+
+    @Benchmark
+    fun benchmark(bh: Blackhole) {
+        analyzeGreenFile(bh)
+    }
+
+    override fun buildText() =
+            """
+            |fun <T> foo(x: Int): T = null!!
+            |fun expectsInt(x: Int) {}
+            |fun bar(v: Int) {
+            |${(1..size).map { "    expectsInt(foo(v))" }.joinToString("\n")}
+            |}
+            """.trimMargin()
+}
\ No newline at end of file
diff --git a/benchmarks/src/org/jetbrains/kotlin/benchmarks/IntArrayPlusBenchmark.kt b/benchmarks/src/org/jetbrains/kotlin/benchmarks/IntArrayPlusBenchmark.kt
new file mode 100644
index 0000000..b969c38
--- /dev/null
+++ b/benchmarks/src/org/jetbrains/kotlin/benchmarks/IntArrayPlusBenchmark.kt
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2010-2019 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 IntArrayPlusBenchmark : AbstractSimpleFileBenchmark() {
+
+    @Param("1", "10", "100", "1000", "3000", "5000", "7000", "10000")
+    private var size: Int = 0
+
+    @Benchmark
+    //@Fork(jvmArgsAppend = ["-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005"])
+    fun benchmark(bh: Blackhole) {
+        if (!isIR) error("Doesn't make sense to run it on old frontend on buildserver")
+        analyzeGreenFile(bh)
+    }
+
+    override fun buildText() =
+            """
+            |fun bar(x: IntArray, y: IntArray) {
+            |${(1..size).joinToString("\n") { "    x + y" }}
+            |}
+            """.trimMargin()
+}
\ No newline at end of file
diff --git a/benchmarks/src/org/jetbrains/kotlin/benchmarks/ManyValsBenchmark.kt b/benchmarks/src/org/jetbrains/kotlin/benchmarks/ManyValsBenchmark.kt
new file mode 100644
index 0000000..d4f761a
--- /dev/null
+++ b/benchmarks/src/org/jetbrains/kotlin/benchmarks/ManyValsBenchmark.kt
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2010-2019 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 ManyValsBenchmark : AbstractSimpleFileBenchmark(){
+
+    @Param("1", "100", "1000", "3000", "5000", "7000", "10000")
+    private var size: Int = 0
+
+    @Benchmark
+    fun benchmark(bh: Blackhole) {
+        analyzeGreenFile(bh)
+    }
+
+    override fun buildText() =
+            """
+            |fun bar() {
+            |${(1..size).joinToString("\n") { "    val x$it: Int = 1" }}
+            |}
+            """.trimMargin()
+}
\ No newline at end of file
diff --git a/benchmarks/src/org/jetbrains/kotlin/benchmarks/ManyVarsBenchmark.kt b/benchmarks/src/org/jetbrains/kotlin/benchmarks/ManyVarsBenchmark.kt
new file mode 100644
index 0000000..eced6a7
--- /dev/null
+++ b/benchmarks/src/org/jetbrains/kotlin/benchmarks/ManyVarsBenchmark.kt
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2010-2019 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 ManyVarsBenchmark : AbstractSimpleFileBenchmark(){
+
+    @Param("1", "100", "1000", "3000", "5000", "7000", "10000")
+    private var size: Int = 0
+
+    @Benchmark
+    fun benchmark(bh: Blackhole) {
+        analyzeGreenFile(bh)
+    }
+
+    override fun buildText() =
+            """
+            |fun bar() {
+            |${(1..size).joinToString("\n") { "    var x$it: Int = 1" }}
+            |}
+            """.trimMargin()
+}
\ No newline at end of file
diff --git a/benchmarks/src/org/jetbrains/kotlin/benchmarks/SimpleDataFlowBenchmark.kt b/benchmarks/src/org/jetbrains/kotlin/benchmarks/SimpleDataFlowBenchmark.kt
new file mode 100644
index 0000000..37e0229
--- /dev/null
+++ b/benchmarks/src/org/jetbrains/kotlin/benchmarks/SimpleDataFlowBenchmark.kt
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2010-2019 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 SimpleDataFlowBenchmark : AbstractSimpleFileBenchmark(){
+
+    @Param("1", "100", "1000", "3000", "5000", "7000", "10000")
+    private var size: Int = 0
+
+    @Benchmark
+    fun benchmark(bh: Blackhole) {
+        analyzeGreenFile(bh)
+    }
+
+    override fun buildText() =
+            """
+            |fun foo(x: Int): Int = 1
+            |var x = 1
+            |fun bar(v: Int) {
+            |${(1..size).joinToString("\n") { "    x = foo(v)" }}
+            |}
+            """.trimMargin()
+
+
+}
\ No newline at end of file
diff --git a/gradle/javaInstrumentation.gradle.kts b/gradle/javaInstrumentation.gradle.kts
index 6372610..e0b8b6d 100644
--- a/gradle/javaInstrumentation.gradle.kts
+++ b/gradle/javaInstrumentation.gradle.kts
@@ -43,7 +43,7 @@
         )
     }
 
-    val sourceSet = project.sourceSets.single { it.compileJavaTaskName == name }
+    val sourceSet = project.sourceSets.singleOrNull { it.compileJavaTaskName == name } ?: return
 
     val javaSourceDirectories = sourceSet.allJava.sourceDirectories.filter { it.exists() }
 
diff --git a/settings.gradle b/settings.gradle
index e45928b..6291675 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -20,6 +20,7 @@
 
 // modules
 include ":kotlin-build-common",
+        ":benchmarks",
         ":compiler",
         ":compiler:util",
         ":kotlin-util-io",