From bb4cf08d0b943e81e73a94df5c5c4067463d8e25 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Thu, 19 Apr 2018 17:50:35 +0300 Subject: [PATCH] Light class performance test: evaluate all supertypes / methods / fields So #KT-24085 In Progress --- .../kotlin/idea/perf/AllKotlinLightClassTest.kt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/idea/performanceTests/org/jetbrains/kotlin/idea/perf/AllKotlinLightClassTest.kt b/idea/performanceTests/org/jetbrains/kotlin/idea/perf/AllKotlinLightClassTest.kt index f0ec8464b6a..c55a8f2b1fd 100644 --- a/idea/performanceTests/org/jetbrains/kotlin/idea/perf/AllKotlinLightClassTest.kt +++ b/idea/performanceTests/org/jetbrains/kotlin/idea/perf/AllKotlinLightClassTest.kt @@ -6,11 +6,13 @@ package org.jetbrains.kotlin.idea.perf import com.intellij.openapi.vfs.VirtualFile +import org.jetbrains.kotlin.asJava.classes.KtLightClassForSourceDeclaration import org.jetbrains.kotlin.asJava.toLightClass import org.jetbrains.kotlin.cfg.pseudocode.containingDeclarationForPseudocode import org.jetbrains.kotlin.idea.refactoring.toPsiFile import org.jetbrains.kotlin.psi.KtClassOrObject import org.jetbrains.kotlin.psi.KtVisitorVoid +import java.util.* import kotlin.system.measureNanoTime class AllKotlinLightClassTest : WholeProjectPerformanceTest(), WholeProjectKotlinFileProvider { @@ -20,7 +22,7 @@ class AllKotlinLightClassTest : WholeProjectPerformanceTest(), WholeProjectKotli var totalNs = 0L val psiFile = file.toPsiFile(project) ?: run { - return PerFileTestResult(results, totalNs, listOf(AssertionError("PsiFile not found for $file"))) + return WholeProjectPerformanceTest.PerFileTestResult(results, totalNs, listOf(AssertionError("PsiFile not found for $file"))) } val errors = mutableListOf() @@ -31,7 +33,10 @@ class AllKotlinLightClassTest : WholeProjectPerformanceTest(), WholeProjectKotli psiFile.acceptRecursively(object : KtVisitorVoid() { override fun visitClassOrObject(classOrObject: KtClassOrObject) { if (classOrObject.containingDeclarationForPseudocode != null) return - val lightClass = classOrObject.toLightClass() ?: return + val lightClass = classOrObject.toLightClass() as? KtLightClassForSourceDeclaration ?: return + Arrays.hashCode(lightClass.superTypes) + Arrays.hashCode(lightClass.fields) + Arrays.hashCode(lightClass.methods) lightClass.hashCode() } })