VCS widget perf test

GitOrigin-RevId: 123d8570fd18aaa81f1006fbb72718ed2f3b29f8
This commit is contained in:
Veronika Timkina
2023-11-16 17:43:02 +01:00
committed by intellij-monorepo-bot
parent 4ac4699253
commit 59d985157b
6 changed files with 61 additions and 3 deletions

View File

@@ -201,4 +201,11 @@ interface VcsTelemetrySpan {
override fun getName() = "changes-view-refresh-edt"
}
}
enum class GitBranchesPopup : VcsTelemetrySpan {
BuildingTree {
override fun getName() = "git-branches-popup-building-tree"
}
}
}

View File

@@ -14,7 +14,8 @@ public final class GitCommandProvider implements CommandProvider {
Map.entry(GitCheckoutCommand.PREFIX, GitCheckoutCommand::new),
Map.entry(ShowFileHistoryCommand.PREFIX, ShowFileHistoryCommand::new),
Map.entry(GitCommitCommand.PREFIX, GitCommitCommand::new),
Map.entry(FilterVcsLogTabCommand.PREFIX, FilterVcsLogTabCommand::new)
Map.entry(FilterVcsLogTabCommand.PREFIX, FilterVcsLogTabCommand::new),
Map.entry(GitShowVcsWidgetCommand.PREFIX, GitShowVcsWidgetCommand::new)
);
}
}

View File

@@ -0,0 +1,31 @@
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package git4idea.performanceTesting
import com.intellij.openapi.application.EDT
import com.intellij.openapi.ui.playback.PlaybackContext
import com.jetbrains.performancePlugin.commands.PerformanceCommandCoroutineAdapter
import git4idea.repo.GitRepositoryManager
import git4idea.ui.branch.popup.GitBranchesTreePopup
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import kotlin.time.Duration.Companion.minutes
class GitShowVcsWidgetCommand(text: String, line: Int) : PerformanceCommandCoroutineAdapter(text, line) {
companion object {
const val NAME = "gitShowBranchWidget"
const val PREFIX = CMD_PREFIX + NAME
}
@Suppress
override suspend fun doExecute(context: PlaybackContext) {
val repository = GitRepositoryManager.getInstance(context.project).repositories.single()
withContext(Dispatchers.EDT) {
val treePopup = (GitBranchesTreePopup.create(context.project, repository) as GitBranchesTreePopup)
treePopup.showCenteredInCurrentWindow(context.project)
treePopup.waitTreeExpand(3.minutes)
}
}
override fun getName(): String = GitCommitCommand.NAME
}

View File

@@ -14,6 +14,7 @@ import com.intellij.openapi.actionSystem.ex.ActionUtil
import com.intellij.openapi.actionSystem.impl.SimpleDataContext
import com.intellij.openapi.application.runInEdt
import com.intellij.openapi.components.service
import com.intellij.openapi.concurrency.waitForPromise
import com.intellij.openapi.keymap.KeymapUtil
import com.intellij.openapi.project.Project
import com.intellij.openapi.ui.popup.JBPopup
@@ -69,6 +70,7 @@ import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.flow.debounce
import kotlinx.coroutines.flow.drop
import org.jetbrains.annotations.TestOnly
import java.awt.Cursor
import java.awt.Point
import java.awt.event.*
@@ -82,6 +84,7 @@ import javax.swing.tree.TreePath
import javax.swing.tree.TreeSelectionModel
import kotlin.math.min
import kotlin.reflect.KClass
import kotlin.time.Duration
class GitBranchesTreePopup(project: Project, step: GitBranchesTreePopupStep, parent: JBPopup? = null, parentValue: Any? = null)
: WizardPopup(project, parent, step),
@@ -142,7 +145,7 @@ class GitBranchesTreePopup(project: Project, step: GitBranchesTreePopupStep, par
return
}
val searchBorder = mySpeedSearchPatternField.border
val searchBorder = mySpeedSearchPatternField.border
mySpeedSearchPatternField.border = null
val toolbar = createToolbar().component.apply {
@@ -791,4 +794,10 @@ class GitBranchesTreePopup(project: Project, step: GitBranchesTreePopupStep, par
Disposer.register(parent) { it.cancel() }
}
}
@TestOnly
fun waitTreeExpand(timeout: Duration) {
TreeUtil.promiseExpandAll(tree).waitForPromise(timeout)
}
}

View File

@@ -6,6 +6,10 @@ import com.intellij.dvcs.branch.BranchType
import com.intellij.dvcs.getCommonCurrentBranch
import com.intellij.openapi.project.Project
import com.intellij.openapi.util.registry.Registry
import com.intellij.openapi.vcs.VcsScope
import com.intellij.openapi.vcs.telemetry.VcsTelemetrySpan
import com.intellij.platform.diagnostic.telemetry.TelemetryManager.Companion.getInstance
import com.intellij.platform.diagnostic.telemetry.helpers.computeWithSpan
import com.intellij.psi.codeStyle.MinusculeMatcher
import com.intellij.ui.SeparatorWithText
import com.intellij.ui.popup.PopupFactoryImpl
@@ -299,7 +303,9 @@ internal class LazyBranchesSubtreeHolder(
val tree: Map<String, Any> by lazy {
val branchesList = matchingResult.matchedNodes
buildSubTree(branchesList.map { (if (isPrefixGrouping()) it.name.split('/') else listOf(it.name)) to it })
computeWithSpan(getInstance().getTracer(VcsScope), VcsTelemetrySpan.GitBranchesPopup.BuildingTree.getName()) {
buildSubTree(branchesList.map { (if (isPrefixGrouping()) it.name.split('/') else listOf(it.name)) to it })
}
}
val topMatch: GitBranch?

View File

@@ -638,6 +638,10 @@ fun <T : CommandChain> T.filterVcsLogTab(params:Map<String, String>): T = apply
addCommand("${CMD_PREFIX}filterVcsLogTab $cmdParams")
}
fun <T : CommandChain> T.showBranchWidget(): T = apply {
addCommand("${CMD_PREFIX}gitShowBranchWidget")
}
fun <T : CommandChain> T.chooseCompletionCommand(completionName: String): T = apply {
addCommand("${CMD_PREFIX}chooseCompletionCommand ${completionName}")
}