mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[terminal] IJPL-182482 Report backend document update latency
Report it with the length of the updated text. GitOrigin-RevId: bb89d8c5ad1d666147b1b431430608f050fccd70
This commit is contained in:
committed by
intellij-monorepo-bot
parent
320811c078
commit
4c2516c07b
+14
-2
@@ -16,6 +16,7 @@ import org.jetbrains.plugins.terminal.block.reworked.*
|
||||
import org.jetbrains.plugins.terminal.block.ui.TerminalUiUtils
|
||||
import org.jetbrains.plugins.terminal.fus.ReworkedTerminalUsageCollector
|
||||
import kotlin.coroutines.cancellation.CancellationException
|
||||
import kotlin.time.TimeSource
|
||||
|
||||
/**
|
||||
* TerminalSession implementation that stores the state of the [delegate] session output.
|
||||
@@ -81,9 +82,8 @@ internal class StateAwareTerminalSession(private val delegate: TerminalSession)
|
||||
private fun handleEvent(event: TerminalOutputEvent) {
|
||||
when (event) {
|
||||
is TerminalContentUpdatedEvent -> {
|
||||
val styles = event.styles.map { it.toStyleRange() }
|
||||
val model = getCurrentOutputModel()
|
||||
model.updateContent(event.startLineLogicalIndex, event.text, styles)
|
||||
updateOutputModelContent(model, event)
|
||||
|
||||
val latency = event.readTime?.elapsedNow()
|
||||
if (latency != null) {
|
||||
@@ -128,4 +128,16 @@ internal class StateAwareTerminalSession(private val delegate: TerminalSession)
|
||||
private fun getCurrentOutputModel(): TerminalOutputModel {
|
||||
return if (sessionModel.terminalState.value.isAlternateScreenBuffer) alternateBufferModel else outputModel
|
||||
}
|
||||
|
||||
private fun updateOutputModelContent(model: TerminalOutputModel, event: TerminalContentUpdatedEvent) {
|
||||
val startTime = TimeSource.Monotonic.markNow()
|
||||
|
||||
val styles = event.styles.map { it.toStyleRange() }
|
||||
model.updateContent(event.startLineLogicalIndex, event.text, styles)
|
||||
|
||||
ReworkedTerminalUsageCollector.logBackendDocumentUpdateLatency(
|
||||
textLength = event.text.length,
|
||||
duration = startTime.elapsedNow(),
|
||||
)
|
||||
}
|
||||
}
|
||||
+13
@@ -75,6 +75,12 @@ object ReworkedTerminalUsageCollector : CounterUsagesCollector() {
|
||||
DURATION_FIELD,
|
||||
)
|
||||
|
||||
private val backendDocumentUpdateLatencyEvent = GROUP.registerVarargEvent(
|
||||
"terminal.backend.document.update.latency",
|
||||
TEXT_LENGTH_FIELD,
|
||||
DURATION_FIELD,
|
||||
)
|
||||
|
||||
@JvmStatic
|
||||
fun logLocalShellStarted(project: Project, shellCommand: Array<String>) {
|
||||
localShellStartedEvent.log(project,
|
||||
@@ -135,4 +141,11 @@ object ReworkedTerminalUsageCollector : CounterUsagesCollector() {
|
||||
DURATION_FIELD with duration
|
||||
)
|
||||
}
|
||||
|
||||
fun logBackendDocumentUpdateLatency(textLength: Int, duration: Duration) {
|
||||
backendDocumentUpdateLatencyEvent.log(
|
||||
TEXT_LENGTH_FIELD with textLength,
|
||||
DURATION_FIELD with duration
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user