From dcc6579dcbd9c40ca7da02c9cc03ead10e627aac Mon Sep 17 00:00:00 2001 From: Nikolay Krasko Date: Tue, 3 Jul 2018 21:02:32 +0300 Subject: [PATCH] Modification trackers increment highlighting test --- .../HighlightingPerformanceTest.kt | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 idea/tests/org/jetbrains/kotlin/idea/highlighter/HighlightingPerformanceTest.kt diff --git a/idea/tests/org/jetbrains/kotlin/idea/highlighter/HighlightingPerformanceTest.kt b/idea/tests/org/jetbrains/kotlin/idea/highlighter/HighlightingPerformanceTest.kt new file mode 100644 index 00000000000..8ef7d95fc49 --- /dev/null +++ b/idea/tests/org/jetbrains/kotlin/idea/highlighter/HighlightingPerformanceTest.kt @@ -0,0 +1,51 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. 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.idea.highlighter + +import com.intellij.psi.PsiManager +import com.intellij.psi.impl.PsiModificationTrackerImpl +import com.intellij.testFramework.LightProjectDescriptor +import com.intellij.testFramework.PlatformTestUtil +import org.jetbrains.kotlin.idea.test.KotlinLightCodeInsightFixtureTestCase +import org.jetbrains.kotlin.idea.test.KotlinWithJdkAndRuntimeLightProjectDescriptor + +class HighlightingPerformanceTest : KotlinLightCodeInsightFixtureTestCase() { + private val text = """ + fun test(a: String, b: ArrayList) { + println(a + b) + } + """.trimIndent() + + fun testModificationCountInc() { + myFixture.configureByText("temp.kt", text) + highlight() + + val tracker = PsiManager.getInstance(myFixture.project).modificationTracker as PsiModificationTrackerImpl + + PlatformTestUtil.assertTiming("Update local cache", 100) { // actual timing is ~55 + tracker.modificationCount.inc() + highlight() + } + } + + fun testOutOfBlockModificationCountInc() { + myFixture.configureByText("temp.kt", text) + highlight() + + val tracker = PsiManager.getInstance(myFixture.project).modificationTracker as PsiModificationTrackerImpl + + PlatformTestUtil.assertTiming("Update all trackers", 200) { // actual timing is ~165 + tracker.incOutOfCodeBlockModificationCounter() + highlight() + } + } + + override fun getProjectDescriptor(): LightProjectDescriptor = KotlinWithJdkAndRuntimeLightProjectDescriptor.INSTANCE_FULL_JDK + + private fun highlight() { + myFixture.checkHighlighting(true, false, true) + } +} \ No newline at end of file