Init default profile for perf tests
This commit is contained in:
+1
@@ -170,6 +170,7 @@ abstract class AbstractPerformanceProjectsTest : UsefulTestCase() {
|
||||
it.value?.let { project ->
|
||||
lastProject = project
|
||||
openAction.postOpenProject(openProject = openProject, project = project)
|
||||
openAction.initDefaultProfile(project)
|
||||
|
||||
logMessage { "project '$name' successfully opened" }
|
||||
|
||||
|
||||
+27
-31
@@ -269,44 +269,40 @@ class PerformanceProjectsTest : AbstractPerformanceProjectsTest() {
|
||||
note: String = ""
|
||||
) {
|
||||
val project = myProject!!
|
||||
val disposable = Disposer.newDisposable("perfKtsFileAnalysis $fileName")
|
||||
//val disposable = Disposer.newDisposable("perfKtsFileAnalysis $fileName")
|
||||
|
||||
enableAllInspectionsCompat(project, disposable)
|
||||
//enableAllInspectionsCompat(project, disposable)
|
||||
|
||||
replaceWithCustomHighlighter()
|
||||
|
||||
try {
|
||||
highlightFile {
|
||||
val testName = "fileAnalysis ${notePrefix(note)}${simpleFilename(fileName)}"
|
||||
val extraStats = Stats("${stats.name} $testName")
|
||||
val extraTimingsNs = mutableListOf<Map<String, Any>?>()
|
||||
highlightFile {
|
||||
val testName = "fileAnalysis ${notePrefix(note)}${simpleFilename(fileName)}"
|
||||
val extraStats = Stats("${stats.name} $testName")
|
||||
val extraTimingsNs = mutableListOf<Map<String, Any>?>()
|
||||
|
||||
val warmUpIterations = 20
|
||||
val iterations = 30
|
||||
val warmUpIterations = 20
|
||||
val iterations = 30
|
||||
|
||||
performanceTest<Fixture, Pair<Long, List<HighlightInfo>>> {
|
||||
name(testName)
|
||||
stats(stats)
|
||||
warmUpIterations(30)
|
||||
iterations(50)
|
||||
setUp(perfKtsFileAnalysisSetUp(project, fileName))
|
||||
test(perfKtsFileAnalysisTest())
|
||||
tearDown(perfKtsFileAnalysisTearDown(extraTimingsNs, project))
|
||||
profilerEnabled(true)
|
||||
}
|
||||
|
||||
extraStats.printWarmUpTimings(
|
||||
"annotator",
|
||||
extraTimingsNs.take(warmUpIterations).toTypedArray()
|
||||
)
|
||||
|
||||
extraStats.appendTimings(
|
||||
"annotator",
|
||||
extraTimingsNs.drop(warmUpIterations).toTypedArray()
|
||||
)
|
||||
performanceTest<Fixture, Pair<Long, List<HighlightInfo>>> {
|
||||
name(testName)
|
||||
stats(stats)
|
||||
warmUpIterations(30)
|
||||
iterations(50)
|
||||
setUp(perfKtsFileAnalysisSetUp(project, fileName))
|
||||
test(perfKtsFileAnalysisTest())
|
||||
tearDown(perfKtsFileAnalysisTearDown(extraTimingsNs, project))
|
||||
profilerEnabled(true)
|
||||
}
|
||||
} finally {
|
||||
Disposer.dispose(disposable)
|
||||
|
||||
extraStats.printWarmUpTimings(
|
||||
"annotator",
|
||||
extraTimingsNs.take(warmUpIterations).toTypedArray()
|
||||
)
|
||||
|
||||
extraStats.appendTimings(
|
||||
"annotator",
|
||||
extraTimingsNs.drop(warmUpIterations).toTypedArray()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -148,6 +148,7 @@ class KotlinFileSource : AbstractSource() {
|
||||
class ProjectBuilder {
|
||||
internal var buildGradle: String? = null
|
||||
internal lateinit var name: String
|
||||
internal var initDefaultProfile: Boolean = true
|
||||
private val kotlinFiles = mutableListOf<Pair<String, KotlinFileSource>>()
|
||||
|
||||
fun buildGradle(buildGradle: String) {
|
||||
@@ -158,6 +159,14 @@ class ProjectBuilder {
|
||||
this.name = name
|
||||
}
|
||||
|
||||
fun initDefaultProfile() {
|
||||
this.initDefaultProfile = true
|
||||
}
|
||||
|
||||
fun initDefaultProfile(initDefaultProfile: Boolean) {
|
||||
this.initDefaultProfile = initDefaultProfile
|
||||
}
|
||||
|
||||
fun kotlinFile(name: String, kotlinFileSource: KotlinFileSource.() -> Unit) {
|
||||
val source = KotlinFileSource().apply(kotlinFileSource)
|
||||
kotlinFiles.add(Pair(name, source))
|
||||
@@ -223,5 +232,8 @@ fun openProject(initializer: ProjectBuilder.() -> Unit): Project {
|
||||
)
|
||||
val project = ProjectOpenAction.openProject(openProject)
|
||||
openAction.postOpenProject(project = project, openProject = openProject)
|
||||
if (projectBuilder.initDefaultProfile) {
|
||||
openAction.initDefaultProfile(project)
|
||||
}
|
||||
return project
|
||||
}
|
||||
@@ -204,6 +204,9 @@ class Stats(
|
||||
for ((k, v) in statInfo) {
|
||||
if (k == TEST_KEY) continue
|
||||
printStatValue("$n $k", v)
|
||||
(v as? Number)?.let {
|
||||
printTestMetadata(n, k, it)
|
||||
}
|
||||
}
|
||||
|
||||
printTestFinished(n, (statInfo[TEST_KEY] as Long).nsToMs)
|
||||
@@ -363,6 +366,10 @@ class Stats(
|
||||
println("##teamcity[buildStatisticValue key='$name' value='$value']")
|
||||
}
|
||||
|
||||
fun printTestMetadata(testName: String, name: String, value: Number) {
|
||||
println("##teamcity[testMetadata testName='$testName' name='$name' type='number' value='$value']")
|
||||
}
|
||||
|
||||
private fun printTestFinished(testName: String) {
|
||||
println("##teamcity[testFinished name='$testName']")
|
||||
}
|
||||
|
||||
+22
-2
@@ -5,6 +5,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.idea.testFramework
|
||||
|
||||
import com.intellij.codeInspection.ex.InspectionProfileImpl
|
||||
import com.intellij.ide.highlighter.ModuleFileType
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.application.runWriteAction
|
||||
@@ -16,15 +17,18 @@ import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.project.ex.ProjectManagerEx
|
||||
import com.intellij.openapi.projectRoots.Sdk
|
||||
import com.intellij.openapi.roots.ProjectRootManager
|
||||
import com.intellij.openapi.util.Disposer
|
||||
import com.intellij.openapi.vcs.changes.ChangeListManager
|
||||
import com.intellij.openapi.vcs.changes.ChangeListManagerImpl
|
||||
import com.intellij.openapi.vfs.LocalFileSystem
|
||||
import com.intellij.openapi.vfs.VirtualFileManager
|
||||
import com.intellij.profile.codeInspection.ProjectInspectionProfileManager
|
||||
import com.intellij.testFramework.PsiTestUtil
|
||||
import com.intellij.testFramework.UsefulTestCase
|
||||
import com.intellij.testFramework.UsefulTestCase.assertTrue
|
||||
import com.intellij.util.io.exists
|
||||
import org.jetbrains.kotlin.idea.configuration.getModulesWithKotlinFiles
|
||||
import org.jetbrains.kotlin.idea.perf.Stats.Companion.runAndMeasure
|
||||
import org.jetbrains.kotlin.idea.perf.enableAllInspectionsCompat
|
||||
import org.jetbrains.kotlin.idea.project.getAndCacheLanguageLevelByDependencies
|
||||
import org.jetbrains.kotlin.idea.test.ConfigLibraryUtil
|
||||
import java.io.File
|
||||
@@ -131,7 +135,7 @@ enum class ProjectOpenAction {
|
||||
}.get()
|
||||
|
||||
val modules = ModuleManager.getInstance(project).modules
|
||||
UsefulTestCase.assertTrue("project ${openProject.projectName} has to have at least one module", modules.isNotEmpty())
|
||||
assertTrue("project ${openProject.projectName} has to have at least one module", modules.isNotEmpty())
|
||||
|
||||
logMessage { "modules of ${openProject.projectName}: ${modules.map { m -> m.name }}" }
|
||||
|
||||
@@ -140,6 +144,22 @@ enum class ProjectOpenAction {
|
||||
//runWriteAction { project.save() }
|
||||
}
|
||||
|
||||
fun initDefaultProfile(project: Project) {
|
||||
val projectInspectionProfileManager = ProjectInspectionProfileManager.getInstance(project)
|
||||
projectInspectionProfileManager.forceLoadSchemes()
|
||||
|
||||
val projectProfile = projectInspectionProfileManager.projectProfile ?: error("project has to have non null profile name")
|
||||
val profile = projectInspectionProfileManager.getProfile(projectProfile)
|
||||
InspectionProfileImpl.INIT_INSPECTIONS = true
|
||||
profile.initInspectionTools(project)
|
||||
val enabledTools = profile.getAllEnabledInspectionTools(project)
|
||||
assertTrue(
|
||||
"project ${project.name} has to have at least one enabled inspection in profile",
|
||||
enabledTools.isNotEmpty()
|
||||
)
|
||||
InspectionProfileImpl.INIT_INSPECTIONS = false
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun openProject(openProject: OpenProject): Project {
|
||||
val project = openProject.projectOpenAction.openProject(
|
||||
|
||||
Reference in New Issue
Block a user