Reformat AbstractSimpleFileBenchmark.kt
This commit is contained in:
@@ -66,10 +66,10 @@ 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 RUNTIME_JAR = File(System.getProperty("kotlin.runtime.path") ?: "dist/kotlinc/lib/kotlin-runtime.jar")
|
||||||
|
|
||||||
private val LANGUAGE_FEATURE_SETTINGS =
|
private val LANGUAGE_FEATURE_SETTINGS =
|
||||||
LanguageVersionSettingsImpl(
|
LanguageVersionSettingsImpl(
|
||||||
LanguageVersion.KOTLIN_1_3, ApiVersion.KOTLIN_1_3,
|
LanguageVersion.KOTLIN_1_3, ApiVersion.KOTLIN_1_3,
|
||||||
specificFeatures = mapOf(LanguageFeature.NewInference to LanguageFeature.State.ENABLED)
|
specificFeatures = mapOf(LanguageFeature.NewInference to LanguageFeature.State.ENABLED)
|
||||||
)
|
)
|
||||||
|
|
||||||
private fun newConfiguration(useNewInference: Boolean): CompilerConfiguration {
|
private fun newConfiguration(useNewInference: Boolean): CompilerConfiguration {
|
||||||
val configuration = CompilerConfiguration()
|
val configuration = CompilerConfiguration()
|
||||||
@@ -81,10 +81,10 @@ private fun newConfiguration(useNewInference: Boolean): CompilerConfiguration {
|
|||||||
|
|
||||||
val newInferenceState = if (useNewInference) LanguageFeature.State.ENABLED else LanguageFeature.State.DISABLED
|
val newInferenceState = if (useNewInference) LanguageFeature.State.ENABLED else LanguageFeature.State.DISABLED
|
||||||
configuration.languageVersionSettings = LanguageVersionSettingsImpl(
|
configuration.languageVersionSettings = LanguageVersionSettingsImpl(
|
||||||
LanguageVersion.KOTLIN_1_3, ApiVersion.KOTLIN_1_3,
|
LanguageVersion.KOTLIN_1_3, ApiVersion.KOTLIN_1_3,
|
||||||
specificFeatures = mapOf(
|
specificFeatures = mapOf(
|
||||||
LanguageFeature.NewInference to newInferenceState
|
LanguageFeature.NewInference to newInferenceState
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
return configuration
|
return configuration
|
||||||
}
|
}
|
||||||
@@ -105,21 +105,21 @@ abstract class AbstractSimpleFileBenchmark {
|
|||||||
fun setUp() {
|
fun setUp() {
|
||||||
if (isIR && !useNewInference) error("Invalid configuration")
|
if (isIR && !useNewInference) error("Invalid configuration")
|
||||||
env = KotlinCoreEnvironment.createForTests(
|
env = KotlinCoreEnvironment.createForTests(
|
||||||
myDisposable,
|
myDisposable,
|
||||||
newConfiguration(useNewInference),
|
newConfiguration(useNewInference),
|
||||||
EnvironmentConfigFiles.JVM_CONFIG_FILES
|
EnvironmentConfigFiles.JVM_CONFIG_FILES
|
||||||
)
|
)
|
||||||
|
|
||||||
if (isIR) {
|
if (isIR) {
|
||||||
Extensions.getArea(env.project)
|
Extensions.getArea(env.project)
|
||||||
.getExtensionPoint(PsiElementFinder.EP_NAME)
|
.getExtensionPoint(PsiElementFinder.EP_NAME)
|
||||||
.unregisterExtension(JavaElementFinder::class.java)
|
.unregisterExtension(JavaElementFinder::class.java)
|
||||||
}
|
}
|
||||||
|
|
||||||
file = createFile(
|
file = createFile(
|
||||||
"test.kt",
|
"test.kt",
|
||||||
buildText(),
|
buildText(),
|
||||||
env.project
|
env.project
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -134,22 +134,22 @@ abstract class AbstractSimpleFileBenchmark {
|
|||||||
private fun analyzeGreenFileFrontend(bh: Blackhole) {
|
private fun analyzeGreenFileFrontend(bh: Blackhole) {
|
||||||
val tracker = ExceptionTracker()
|
val tracker = ExceptionTracker()
|
||||||
val storageManager: StorageManager =
|
val storageManager: StorageManager =
|
||||||
LockBasedStorageManager.createWithExceptionHandling("benchmarks", tracker)
|
LockBasedStorageManager.createWithExceptionHandling("benchmarks", tracker)
|
||||||
|
|
||||||
val context = SimpleGlobalContext(storageManager, tracker)
|
val context = SimpleGlobalContext(storageManager, tracker)
|
||||||
val module =
|
val module =
|
||||||
ModuleDescriptorImpl(
|
ModuleDescriptorImpl(
|
||||||
Name.special("<benchmark>"), storageManager,
|
Name.special("<benchmark>"), storageManager,
|
||||||
JvmBuiltIns(storageManager, JvmBuiltIns.Kind.FROM_DEPENDENCIES)
|
JvmBuiltIns(storageManager, JvmBuiltIns.Kind.FROM_DEPENDENCIES)
|
||||||
)
|
)
|
||||||
val moduleContext = context.withProject(env.project).withModule(module)
|
val moduleContext = context.withProject(env.project).withModule(module)
|
||||||
|
|
||||||
val result = TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(
|
val result = TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(
|
||||||
moduleContext.project,
|
moduleContext.project,
|
||||||
listOf(file),
|
listOf(file),
|
||||||
NoScopeRecordCliBindingTrace(),
|
NoScopeRecordCliBindingTrace(),
|
||||||
env.configuration,
|
env.configuration,
|
||||||
{ scope -> JvmPackagePartProvider(LANGUAGE_FEATURE_SETTINGS, scope) }
|
{ scope -> JvmPackagePartProvider(LANGUAGE_FEATURE_SETTINGS, scope) }
|
||||||
)
|
)
|
||||||
|
|
||||||
assert(result.bindingContext.diagnostics.none { it.severity == Severity.ERROR })
|
assert(result.bindingContext.diagnostics.none { it.severity == Severity.ERROR })
|
||||||
@@ -159,7 +159,7 @@ abstract class AbstractSimpleFileBenchmark {
|
|||||||
|
|
||||||
private fun analyzeGreenFileIr(bh: Blackhole) {
|
private fun analyzeGreenFileIr(bh: Blackhole) {
|
||||||
val scope = GlobalSearchScope.filesScope(env.project, listOf(file.virtualFile))
|
val scope = GlobalSearchScope.filesScope(env.project, listOf(file.virtualFile))
|
||||||
.uniteWith(TopDownAnalyzerFacadeForJVM.AllJavaSourcesInProjectScope(env.project))
|
.uniteWith(TopDownAnalyzerFacadeForJVM.AllJavaSourcesInProjectScope(env.project))
|
||||||
val session = createSession(env, scope)
|
val session = createSession(env, scope)
|
||||||
val firProvider = session.firProvider as FirProviderImpl
|
val firProvider = session.firProvider as FirProviderImpl
|
||||||
val builder = RawFirBuilder(session, firProvider.kotlinScopeProvider, stubMode = false)
|
val builder = RawFirBuilder(session, firProvider.kotlinScopeProvider, stubMode = false)
|
||||||
@@ -176,9 +176,9 @@ abstract class AbstractSimpleFileBenchmark {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun createSession(
|
fun createSession(
|
||||||
environment: KotlinCoreEnvironment,
|
environment: KotlinCoreEnvironment,
|
||||||
sourceScope: GlobalSearchScope,
|
sourceScope: GlobalSearchScope,
|
||||||
librariesScope: GlobalSearchScope = GlobalSearchScope.notScope(sourceScope)
|
librariesScope: GlobalSearchScope = GlobalSearchScope.notScope(sourceScope)
|
||||||
): FirSession {
|
): FirSession {
|
||||||
val moduleInfo = FirTestModuleInfo()
|
val moduleInfo = FirTestModuleInfo()
|
||||||
val project = environment.project
|
val project = environment.project
|
||||||
@@ -189,24 +189,24 @@ fun createSession(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun createSessionForDependencies(
|
private fun createSessionForDependencies(
|
||||||
provider: FirProjectSessionProvider,
|
provider: FirProjectSessionProvider,
|
||||||
moduleInfo: FirTestModuleInfo,
|
moduleInfo: FirTestModuleInfo,
|
||||||
librariesScope: GlobalSearchScope,
|
librariesScope: GlobalSearchScope,
|
||||||
environment: KotlinCoreEnvironment
|
environment: KotlinCoreEnvironment
|
||||||
) {
|
) {
|
||||||
val dependenciesInfo = FirTestModuleInfo()
|
val dependenciesInfo = FirTestModuleInfo()
|
||||||
moduleInfo.dependencies.add(dependenciesInfo)
|
moduleInfo.dependencies.add(dependenciesInfo)
|
||||||
FirLibrarySession.create(
|
FirLibrarySession.create(
|
||||||
dependenciesInfo, provider, librariesScope, environment.project,
|
dependenciesInfo, provider, librariesScope, environment.project,
|
||||||
environment.createPackagePartProvider(librariesScope)
|
environment.createPackagePartProvider(librariesScope)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
class FirTestModuleInfo(
|
class FirTestModuleInfo(
|
||||||
override val name: Name = Name.identifier("TestModule"),
|
override val name: Name = Name.identifier("TestModule"),
|
||||||
val dependencies: MutableList<ModuleInfo> = mutableListOf(),
|
val dependencies: MutableList<ModuleInfo> = mutableListOf(),
|
||||||
override val platform: TargetPlatform = JvmPlatforms.unspecifiedJvmPlatform,
|
override val platform: TargetPlatform = JvmPlatforms.unspecifiedJvmPlatform,
|
||||||
override val analyzerServices: PlatformDependentAnalyzerServices = JvmPlatformAnalyzerServices
|
override val analyzerServices: PlatformDependentAnalyzerServices = JvmPlatformAnalyzerServices
|
||||||
) : ModuleInfo {
|
) : ModuleInfo {
|
||||||
override fun dependencies(): List<ModuleInfo> = dependencies
|
override fun dependencies(): List<ModuleInfo> = dependencies
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user