Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ export class CWInlineCompletionItemProvider implements vscode.InlineCompletionIt
ImportAdderProvider.instance.onShowRecommendation(document, this.startPos.line, r)
this.nextMove = 0
TelemetryHelper.instance.setFirstSuggestionShowTime()
session.setPerceivedLatency()
this._onDidShow.fire()
if (matchedCount >= 2 || this.nextToken !== '') {
const result = [item]
Expand Down
12 changes: 12 additions & 0 deletions packages/core/src/codewhisperer/util/codeWhispererSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class CodeWhispererSession {
invokeSuggestionStartTime = 0
timeToFirstRecommendation = 0
firstSuggestionShowTime = 0
perceivedLatency = 0

public static get instance() {
return (this.#instance ??= new CodeWhispererSession())
Expand Down Expand Up @@ -91,6 +92,17 @@ class CodeWhispererSession {
}
}

setPerceivedLatency() {
if (this.perceivedLatency !== 0) {
return
}
if (this.triggerType === 'OnDemand') {
this.perceivedLatency = this.timeToFirstRecommendation
} else {
this.perceivedLatency = this.firstSuggestionShowTime - vsCodeState.lastUserModificationTime
}
}

reset() {
this.sessionId = ''
this.requestContext = { request: {} as any, supplementalMetadata: {} as any }
Expand Down
5 changes: 2 additions & 3 deletions packages/core/src/codewhisperer/util/telemetryHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -325,9 +325,7 @@ export class TelemetryHelper {
suggestionState: this.getSendTelemetrySuggestionState(aggregatedSuggestionState),
recommendationLatencyMilliseconds: e2eLatency,
triggerToResponseLatencyMilliseconds: session.timeToFirstRecommendation,
perceivedLatencyMilliseconds: session.getPerceivedLatency(
this.sessionDecisions[0].codewhispererTriggerType
),
perceivedLatencyMilliseconds: session.perceivedLatency,
timestamp: new Date(Date.now()),
suggestionReferenceCount: referenceCount,
generatedLine: generatedLines,
Expand Down Expand Up @@ -388,6 +386,7 @@ export class TelemetryHelper {
this.typeAheadLength = 0
this.timeSinceLastModification = 0
session.timeToFirstRecommendation = 0
session.perceivedLatency = 0
this.classifierResult = undefined
this.classifierThreshold = undefined
}
Expand Down
Loading