diff --git a/packages/amazonq/src/app/inline/activation.ts b/packages/amazonq/src/app/inline/activation.ts index 63038e0fd3c..12deb2310fa 100644 --- a/packages/amazonq/src/app/inline/activation.ts +++ b/packages/amazonq/src/app/inline/activation.ts @@ -98,10 +98,10 @@ export async function activate(languageClient: LanguageClient) { if (vsCodeState.lastUserModificationTime) { TelemetryHelper.instance.setTimeSinceLastModification( - performance.now() - vsCodeState.lastUserModificationTime + Date.now() - vsCodeState.lastUserModificationTime ) } - vsCodeState.lastUserModificationTime = performance.now() + vsCodeState.lastUserModificationTime = Date.now() /** * Important: Doing this sleep(10) is to make sure * 1. this event is processed by vs code first diff --git a/packages/amazonq/src/app/inline/completion.ts b/packages/amazonq/src/app/inline/completion.ts index 4a0282b1d05..9c4f8e3ad20 100644 --- a/packages/amazonq/src/app/inline/completion.ts +++ b/packages/amazonq/src/app/inline/completion.ts @@ -115,7 +115,7 @@ export class InlineCompletionManager implements Disposable { const startLine = position.line // TODO: also log the seen state for other suggestions in session // Calculate timing metrics before diagnostic delay - const totalSessionDisplayTime = performance.now() - requestStartTime + const totalSessionDisplayTime = Date.now() - requestStartTime await sleep(500) const diagnosticDiff = getDiagnosticsDifferences( this.sessionManager.getActiveSession()?.diagnosticsBeforeAccept, @@ -175,7 +175,7 @@ export class InlineCompletionManager implements Disposable { return } const requestStartTime = session.requestStartTime - const totalSessionDisplayTime = performance.now() - requestStartTime + const totalSessionDisplayTime = Date.now() - requestStartTime await commands.executeCommand('editor.action.inlineSuggest.hide') // TODO: also log the seen state for other suggestions in session this.disposable.dispose() @@ -249,7 +249,7 @@ export class AmazonQInlineCompletionItemProvider implements InlineCompletionItem // Use VS Code command to check if inline suggestion is actually visible on screen // This command only executes when inlineSuggestionVisible context is true await vscode.commands.executeCommand('aws.amazonq.checkInlineSuggestionVisibility') - const isInlineSuggestionVisible = performance.now() - session.lastVisibleTime < 50 + const isInlineSuggestionVisible = Date.now() - session.lastVisibleTime < 50 return isInlineSuggestionVisible } @@ -278,7 +278,7 @@ export class AmazonQInlineCompletionItemProvider implements InlineCompletionItem sessionId: session.sessionId, completionSessionResult, firstCompletionDisplayLatency: session.firstCompletionDisplayLatency, - totalSessionDisplayTime: performance.now() - session.requestStartTime, + totalSessionDisplayTime: Date.now() - session.requestStartTime, } this.languageClient.sendNotification(this.logSessionResultMessageName, params) } @@ -309,7 +309,7 @@ export class AmazonQInlineCompletionItemProvider implements InlineCompletionItem // when hitting other keystrokes, the context.triggerKind is Automatic (1) // we only mark option + C as manual trigger // this is a workaround since the inlineSuggest.trigger command take no params - const isAutoTrigger = performance.now() - vsCodeState.lastManualTriggerTime > 50 + const isAutoTrigger = Date.now() - vsCodeState.lastManualTriggerTime > 50 if (isAutoTrigger && !CodeSuggestionsState.instance.isSuggestionsEnabled()) { // return early when suggestions are disabled with auto trigger return [] @@ -318,9 +318,9 @@ export class AmazonQInlineCompletionItemProvider implements InlineCompletionItem // yield event loop to let the document listen catch updates await sleep(1) - let logstr = `GenerateCompletion metadata:\\n` + let logstr = `GenerateCompletion activity:\\n` try { - const t0 = performance.now() + const t0 = Date.now() vsCodeState.isRecommendationsActive = true // handling previous session const prevSession = this.sessionManager.getActiveSession() @@ -365,7 +365,7 @@ export class AmazonQInlineCompletionItemProvider implements InlineCompletionItem // re-use previous suggestions as long as new typed prefix matches if (prevItemMatchingPrefix.length > 0) { logstr += `- not call LSP and reuse previous suggestions that match user typed characters - - duration between trigger to completion suggestion is displayed ${performance.now() - t0}` + - duration between trigger to completion suggestion is displayed ${Date.now() - t0}` void this.checkWhetherInlineCompletionWasShown() return prevItemMatchingPrefix } @@ -381,7 +381,7 @@ export class AmazonQInlineCompletionItemProvider implements InlineCompletionItem }, }, firstCompletionDisplayLatency: prevSession.firstCompletionDisplayLatency, - totalSessionDisplayTime: performance.now() - prevSession.requestStartTime, + totalSessionDisplayTime: Date.now() - prevSession.requestStartTime, } this.languageClient.sendNotification(this.logSessionResultMessageName, params) this.sessionManager.clear() @@ -396,7 +396,7 @@ export class AmazonQInlineCompletionItemProvider implements InlineCompletionItem TelemetryHelper.instance.setInvokeSuggestionStartTime() TelemetryHelper.instance.setTriggerType(context.triggerKind) - const t1 = performance.now() + const t1 = Date.now() await this.recommendationService.getAllRecommendations( this.languageClient, @@ -418,7 +418,7 @@ export class AmazonQInlineCompletionItemProvider implements InlineCompletionItem // eslint-disable-next-line @typescript-eslint/no-base-to-string const itemLog = items[0] ? `${items[0].insertText.toString()}` : `no suggestion` - const t2 = performance.now() + const t2 = Date.now() logstr += `- number of suggestions: ${items.length} - sessionId: ${this.sessionManager.getActiveSession()?.sessionId} @@ -468,7 +468,7 @@ ${itemLog} const lastDocumentChange = this.documentEventListener.getLastDocumentChangeEvent(document.uri.fsPath) if ( lastDocumentChange && - performance.now() - lastDocumentChange.timestamp < CodeWhispererConstants.inlineSuggestionShowDelay + Date.now() - lastDocumentChange.timestamp < CodeWhispererConstants.inlineSuggestionShowDelay ) { await sleep(CodeWhispererConstants.showRecommendationTimerPollPeriod) } else { @@ -486,7 +486,7 @@ ${itemLog} // Check if Next Edit Prediction feature flag is enabled if (Experiments.instance.get('amazonqLSPNEP', true)) { await showEdits(item, editor, session, this.languageClient, this) - logstr += `- duration between trigger to edits suggestion is displayed: ${performance.now() - t0}ms` + logstr += `- duration between trigger to edits suggestion is displayed: ${Date.now() - t0}ms` } return [] } @@ -530,7 +530,7 @@ ${itemLog} this.sessionManager.updateCodeReferenceAndImports() // suggestions returned here will be displayed on screen - logstr += `- duration between trigger to completion suggestion is displayed: ${performance.now() - t0}ms` + logstr += `- duration between trigger to completion suggestion is displayed: ${Date.now() - t0}ms` void this.checkWhetherInlineCompletionWasShown() return itemsMatchingTypeahead as InlineCompletionItem[] } catch (e) { diff --git a/packages/amazonq/src/app/inline/documentEventListener.ts b/packages/amazonq/src/app/inline/documentEventListener.ts index 36f65dc7331..7af22a3015a 100644 --- a/packages/amazonq/src/app/inline/documentEventListener.ts +++ b/packages/amazonq/src/app/inline/documentEventListener.ts @@ -20,7 +20,7 @@ export class DocumentEventListener { if (this.lastDocumentChangeEventMap.size > this._maxDocument) { this.lastDocumentChangeEventMap.clear() } - this.lastDocumentChangeEventMap.set(e.document.uri.fsPath, { event: e, timestamp: performance.now() }) + this.lastDocumentChangeEventMap.set(e.document.uri.fsPath, { event: e, timestamp: Date.now() }) // The VS Code provideInlineCompletionCallback may not trigger when Enter is pressed, especially in Python files // manually make this trigger. In case of duplicate, the provideInlineCompletionCallback is already debounced if (this.isEnter(e) && vscode.window.activeTextEditor) { @@ -37,7 +37,7 @@ export class DocumentEventListener { const eventTime = result.timestamp const isDelete = (event && event.contentChanges.length === 1 && event.contentChanges[0].text === '') || false - const timeDiff = Math.abs(performance.now() - eventTime) + const timeDiff = Math.abs(Date.now() - eventTime) return timeDiff < 500 && isDelete } return false diff --git a/packages/amazonq/src/app/inline/editSuggestionState.ts b/packages/amazonq/src/app/inline/editSuggestionState.ts index 27bcedd9345..61e4aebd142 100644 --- a/packages/amazonq/src/app/inline/editSuggestionState.ts +++ b/packages/amazonq/src/app/inline/editSuggestionState.ts @@ -8,12 +8,12 @@ */ export class EditSuggestionState { private static isEditSuggestionCurrentlyActive = false - private static displayStartTime = performance.now() + private static displayStartTime = Date.now() static setEditSuggestionActive(active: boolean): void { this.isEditSuggestionCurrentlyActive = active if (active) { - this.displayStartTime = performance.now() + this.displayStartTime = Date.now() } } @@ -22,6 +22,6 @@ export class EditSuggestionState { } static isEditSuggestionDisplayingOverOneSecond(): boolean { - return this.isEditSuggestionActive() && performance.now() - this.displayStartTime > 1000 + return this.isEditSuggestionActive() && Date.now() - this.displayStartTime > 1000 } } diff --git a/packages/amazonq/src/app/inline/recommendationService.ts b/packages/amazonq/src/app/inline/recommendationService.ts index 80833a4ae8f..e9075ff426e 100644 --- a/packages/amazonq/src/app/inline/recommendationService.ts +++ b/packages/amazonq/src/app/inline/recommendationService.ts @@ -102,7 +102,7 @@ export class RecommendationService { if (document.uri.scheme === 'vscode-notebook-cell') { request.fileContextOverride = extractFileContextInNotebooks(document, position) } - const requestStartTime = performance.now() + const requestStartTime = Date.now() const statusBar = CodeWhispererStatusBarManager.instance // Only track telemetry if enabled @@ -126,7 +126,7 @@ export class RecommendationService { nextToken: request.partialResultToken, }, }) - const t0 = performance.now() + const t0 = Date.now() // Best effort estimate of deletion const isTriggerByDeletion = documentEventListener.isLastEventDeletion(document.uri.fsPath) @@ -176,7 +176,7 @@ export class RecommendationService { getLogger().info('Received inline completion response from LSP: %O', { sessionId: result.sessionId, - latency: performance.now() - t0, + latency: Date.now() - t0, itemCount: result.items?.length || 0, items: result.items?.map((item) => ({ itemId: item.itemId, @@ -228,7 +228,7 @@ export class RecommendationService { } TelemetryHelper.instance.setFirstSuggestionShowTime() - const firstCompletionDisplayLatency = performance.now() - requestStartTime + const firstCompletionDisplayLatency = Date.now() - requestStartTime this.sessionManager.startSession( result.sessionId, result.items, diff --git a/packages/amazonq/src/app/inline/sessionManager.ts b/packages/amazonq/src/app/inline/sessionManager.ts index 15d7dbbb8d0..ef2ee2a84d0 100644 --- a/packages/amazonq/src/app/inline/sessionManager.ts +++ b/packages/amazonq/src/app/inline/sessionManager.ts @@ -137,7 +137,7 @@ export class SessionManager { public checkInlineSuggestionVisibility() { if (this.activeSession) { this.activeSession.displayed = true - this.activeSession.lastVisibleTime = performance.now() + this.activeSession.lastVisibleTime = Date.now() } } diff --git a/packages/amazonq/src/app/inline/telemetryHelper.ts b/packages/amazonq/src/app/inline/telemetryHelper.ts index dffd267bee1..41db4c7469a 100644 --- a/packages/amazonq/src/app/inline/telemetryHelper.ts +++ b/packages/amazonq/src/app/inline/telemetryHelper.ts @@ -41,7 +41,7 @@ export class TelemetryHelper { public setInvokeSuggestionStartTime() { this.resetClientComponentLatencyTime() - this._invokeSuggestionStartTime = performance.now() + this._invokeSuggestionStartTime = Date.now() } get invokeSuggestionStartTime(): number { @@ -49,7 +49,7 @@ export class TelemetryHelper { } public setPreprocessEndTime() { - this._preprocessEndTime = performance.now() + this._preprocessEndTime = Date.now() } get preprocessEndTime(): number { @@ -58,7 +58,7 @@ export class TelemetryHelper { public setSdkApiCallStartTime() { if (this._sdkApiCallStartTime === 0) { - this._sdkApiCallStartTime = performance.now() + this._sdkApiCallStartTime = Date.now() } } @@ -68,7 +68,7 @@ export class TelemetryHelper { public setSdkApiCallEndTime() { if (this._sdkApiCallEndTime === 0 && this._sdkApiCallStartTime !== 0) { - this._sdkApiCallEndTime = performance.now() + this._sdkApiCallEndTime = Date.now() } } @@ -78,7 +78,7 @@ export class TelemetryHelper { public setAllPaginationEndTime() { if (this._allPaginationEndTime === 0 && this._sdkApiCallEndTime !== 0) { - this._allPaginationEndTime = performance.now() + this._allPaginationEndTime = Date.now() } } @@ -88,7 +88,7 @@ export class TelemetryHelper { public setFirstSuggestionShowTime() { if (this._firstSuggestionShowTime === 0 && this._sdkApiCallEndTime !== 0) { - this._firstSuggestionShowTime = performance.now() + this._firstSuggestionShowTime = Date.now() } } diff --git a/packages/amazonq/test/unit/app/inline/completion.test.ts b/packages/amazonq/test/unit/app/inline/completion.test.ts index bd38b1c95af..5c8673a0276 100644 --- a/packages/amazonq/test/unit/app/inline/completion.test.ts +++ b/packages/amazonq/test/unit/app/inline/completion.test.ts @@ -43,7 +43,7 @@ describe('AmazonQInlineCompletionItemProvider', function () { const session = { sessionId: 'test-session', firstCompletionDisplayLatency: 100, - requestStartTime: performance.now() - 1000, + requestStartTime: Date.now() - 1000, } provider.batchDiscardTelemetryForEditSuggestion(items, session) @@ -84,7 +84,7 @@ describe('AmazonQInlineCompletionItemProvider', function () { const session = { sessionId: 'test-session', firstCompletionDisplayLatency: 100, - requestStartTime: performance.now() - 1000, + requestStartTime: Date.now() - 1000, } provider.batchDiscardTelemetryForEditSuggestion(items, session) @@ -108,7 +108,7 @@ describe('AmazonQInlineCompletionItemProvider', function () { const session = { sessionId: 'test-session', firstCompletionDisplayLatency: 100, - requestStartTime: performance.now() - 1000, + requestStartTime: Date.now() - 1000, } provider.batchDiscardTelemetryForEditSuggestion(items, session) @@ -166,7 +166,7 @@ describe('AmazonQInlineCompletionItemProvider', function () { mockSessionManager.getActiveSession.returns({ displayed: true, suggestions: [{ isInlineEdit: true }], - lastVisibleTime: performance.now(), + lastVisibleTime: Date.now(), }) const result = await provider.isCompletionActive() @@ -176,7 +176,7 @@ describe('AmazonQInlineCompletionItemProvider', function () { }) it('should return true when VS Code command executes successfully', async function () { - const currentTime = performance.now() + const currentTime = Date.now() mockSessionManager.getActiveSession.returns({ displayed: true, suggestions: [{ isInlineEdit: false }], @@ -192,7 +192,7 @@ describe('AmazonQInlineCompletionItemProvider', function () { }) it('should return false when VS Code command fails', async function () { - const oldTime = performance.now() - 100 // Old timestamp (>50ms ago) + const oldTime = Date.now() - 100 // Old timestamp (>50ms ago) mockSessionManager.getActiveSession.returns({ displayed: true, suggestions: [{ isInlineEdit: false }], diff --git a/packages/core/src/codewhisperer/service/inlineCompletionService.ts b/packages/core/src/codewhisperer/service/inlineCompletionService.ts index 18a7c014b6a..cd37663af49 100644 --- a/packages/core/src/codewhisperer/service/inlineCompletionService.ts +++ b/packages/core/src/codewhisperer/service/inlineCompletionService.ts @@ -55,7 +55,7 @@ export class InlineCompletionService { this._showRecommendationTimer = undefined } this._showRecommendationTimer = setInterval(() => { - const delay = performance.now() - vsCodeState.lastUserModificationTime + const delay = Date.now() - vsCodeState.lastUserModificationTime if (delay < CodeWhispererConstants.inlineSuggestionShowDelay) { return } diff --git a/packages/core/src/codewhisperer/service/keyStrokeHandler.ts b/packages/core/src/codewhisperer/service/keyStrokeHandler.ts index 49ef633a98f..312e31c248a 100644 --- a/packages/core/src/codewhisperer/service/keyStrokeHandler.ts +++ b/packages/core/src/codewhisperer/service/keyStrokeHandler.ts @@ -56,7 +56,7 @@ export class KeyStrokeHandler { return } this.idleTriggerTimer = setInterval(() => { - const duration = (performance.now() - RecommendationHandler.instance.lastInvocationTime) / 1000 + const duration = (Date.now() - RecommendationHandler.instance.lastInvocationTime) / 1000 if (duration < CodeWhispererConstants.invocationTimeIntervalThreshold) { return } diff --git a/packages/core/src/codewhisperer/service/recommendationHandler.ts b/packages/core/src/codewhisperer/service/recommendationHandler.ts index 5abeab17d9b..b354fb60a05 100644 --- a/packages/core/src/codewhisperer/service/recommendationHandler.ts +++ b/packages/core/src/codewhisperer/service/recommendationHandler.ts @@ -106,7 +106,7 @@ export class RecommendationHandler { constructor() { this.requestId = '' this.nextToken = '' - this.lastInvocationTime = performance.now() - CodeWhispererConstants.invocationTimeIntervalThreshold * 1000 + this.lastInvocationTime = Date.now() - CodeWhispererConstants.invocationTimeIntervalThreshold * 1000 this.cancellationToken = new vscode.CancellationTokenSource() this.prev = new vscode.Disposable(() => {}) this.next = new vscode.Disposable(() => {}) @@ -256,7 +256,7 @@ export class RecommendationHandler { } try { - startTime = performance.now() + startTime = Date.now() this.lastInvocationTime = startTime const mappedReq = runtimeLanguageContext.mapToRuntimeLanguage(request) const codewhispererPromise = @@ -265,7 +265,7 @@ export class RecommendationHandler { : client.generateRecommendations(mappedReq) const resp = await this.getServerResponse(triggerType, config.isManualTriggerEnabled, codewhispererPromise) TelemetryHelper.instance.setSdkApiCallEndTime() - latency = startTime !== 0 ? performance.now() - startTime : 0 + latency = startTime !== 0 ? Date.now() - startTime : 0 if ('recommendations' in resp) { recommendations = (resp && resp.recommendations) || [] } else { @@ -277,7 +277,7 @@ export class RecommendationHandler { sessionId = resp?.$response?.httpResponse?.headers['x-amzn-sessionid'] TelemetryHelper.instance.setFirstResponseRequestId(requestId) if (page === 0) { - session.setTimeToFirstRecommendation(performance.now()) + session.setTimeToFirstRecommendation(Date.now()) } if (nextToken === '') { TelemetryHelper.instance.setAllPaginationEndTime() @@ -287,7 +287,7 @@ export class RecommendationHandler { shouldRecordServiceInvocation = false } if (latency === 0) { - latency = startTime !== 0 ? performance.now() - startTime : 0 + latency = startTime !== 0 ? Date.now() - startTime : 0 } getLogger().error('amazonq inline-suggest: Invocation Exception : %s', (error as Error).message) if (isAwsError(error)) { @@ -721,7 +721,7 @@ export class RecommendationHandler { codewhispererCompletionType: session.getCompletionType(0), codewhispererCustomizationArn: getSelectedCustomization().arn, codewhispererLanguage: languageContext.language, - duration: performance.now() - this.lastInvocationTime, + duration: Date.now() - this.lastInvocationTime, passive: true, credentialStartUrl: AuthUtil.instance.startUrl, result: 'Succeeded', diff --git a/packages/core/src/codewhisperer/service/referenceInlineProvider.ts b/packages/core/src/codewhisperer/service/referenceInlineProvider.ts index a90565797fb..6fe0cf122f2 100644 --- a/packages/core/src/codewhisperer/service/referenceInlineProvider.ts +++ b/packages/core/src/codewhisperer/service/referenceInlineProvider.ts @@ -35,7 +35,7 @@ export class ReferenceInlineProvider implements vscode.CodeLensProvider { } public setInlineReference(line: number, suggestion: string, references: References | undefined) { - const startTime = performance.now() + const startTime = Date.now() this.ranges = [] this.refs = [] if ( @@ -53,7 +53,7 @@ export class ReferenceInlineProvider implements vscode.CodeLensProvider { const licenses = [...n].join(', ') this.ranges.push(new vscode.Range(line, 0, line, 1)) this.refs.push(CodeWhispererConstants.suggestionDetailReferenceText(licenses)) - const duration = performance.now() - startTime + const duration = Date.now() - startTime if (duration > 100) { getLogger().warn(`setInlineReference takes ${duration}ms`) } @@ -70,7 +70,7 @@ export class ReferenceInlineProvider implements vscode.CodeLensProvider { document: vscode.TextDocument, token: vscode.CancellationToken ): vscode.CodeLens[] | Thenable { - const startTime = performance.now() + const startTime = Date.now() const codeLenses: vscode.CodeLens[] = [] for (let i = 0; i < this.ranges.length; i++) { const codeLens = new vscode.CodeLens(this.ranges[i]) @@ -82,7 +82,7 @@ export class ReferenceInlineProvider implements vscode.CodeLensProvider { } codeLenses.push(codeLens) } - const duration = performance.now() - startTime + const duration = Date.now() - startTime if (duration > 100) { getLogger().warn(`setInlineReference takes ${duration}ms`) } diff --git a/packages/core/src/codewhisperer/tracker/userWrittenCodeTracker.ts b/packages/core/src/codewhisperer/tracker/userWrittenCodeTracker.ts index 32de471878d..7dfb14b5745 100644 --- a/packages/core/src/codewhisperer/tracker/userWrittenCodeTracker.ts +++ b/packages/core/src/codewhisperer/tracker/userWrittenCodeTracker.ts @@ -53,7 +53,7 @@ export class UserWrittenCodeTracker { // for all Q features public onQFeatureInvoked() { this._qUsageCount += 1 - this._lastQInvocationTime = performance.now() + this._lastQInvocationTime = Date.now() } public onQStartsMakingEdits() { @@ -129,10 +129,10 @@ export class UserWrittenCodeTracker { this.reset() return } - const startTime = performance.now() + const startTime = Date.now() this._timer = setTimeout(() => { try { - const currentTime = performance.now() + const currentTime = Date.now() const delay: number = UserWrittenCodeTracker.defaultCheckPeriodMillis const diffTime: number = startTime + delay if (diffTime <= currentTime) { @@ -169,7 +169,7 @@ export class UserWrittenCodeTracker { // due to unhandled edge cases or early terminated code paths // reset it back to false after a reasonable period of time if (this._qIsMakingEdits) { - if (performance.now() - this._lastQInvocationTime > UserWrittenCodeTracker.resetQIsEditingTimeoutMs) { + if (Date.now() - this._lastQInvocationTime > UserWrittenCodeTracker.resetQIsEditingTimeoutMs) { getLogger().warn(`Reset Q is editing state to false.`) this._qIsMakingEdits = false } diff --git a/packages/core/src/codewhisperer/util/codeWhispererSession.ts b/packages/core/src/codewhisperer/util/codeWhispererSession.ts index 17d9c998112..4a529941004 100644 --- a/packages/core/src/codewhisperer/util/codeWhispererSession.ts +++ b/packages/core/src/codewhisperer/util/codeWhispererSession.ts @@ -53,13 +53,13 @@ class CodeWhispererSession { setFetchCredentialStart() { if (this.fetchCredentialStartTime === 0 && this.invokeSuggestionStartTime !== 0) { - this.fetchCredentialStartTime = performance.now() + this.fetchCredentialStartTime = Date.now() } } setSdkApiCallStart() { if (this.sdkApiCallStartTime === 0 && this.fetchCredentialStartTime !== 0) { - this.sdkApiCallStartTime = performance.now() + this.sdkApiCallStartTime = Date.now() } } diff --git a/packages/core/src/codewhisperer/util/supplementalContext/supplementalContextUtil.ts b/packages/core/src/codewhisperer/util/supplementalContext/supplementalContextUtil.ts index a21bf113b82..edda43ddcf6 100644 --- a/packages/core/src/codewhisperer/util/supplementalContext/supplementalContextUtil.ts +++ b/packages/core/src/codewhisperer/util/supplementalContext/supplementalContextUtil.ts @@ -20,7 +20,7 @@ export async function fetchSupplementalContext( cancellationToken: vscode.CancellationToken, languageClient?: LanguageClient ): Promise { - const timesBeforeFetching = performance.now() + const timesBeforeFetching = Date.now() const isUtg = await isTestFile(editor.document.uri.fsPath, { languageId: editor.document.languageId, @@ -47,7 +47,7 @@ export async function fetchSupplementalContext( (item) => item.content.trim().length !== 0 ), contentsLength: value.supplementalContextItems.reduce((acc, curr) => acc + curr.content.length, 0), - latency: performance.now() - timesBeforeFetching, + latency: Date.now() - timesBeforeFetching, strategy: value.strategy, } @@ -63,7 +63,7 @@ export async function fetchSupplementalContext( isProcessTimeout: true, supplementalContextItems: [], contentsLength: 0, - latency: performance.now() - timesBeforeFetching, + latency: Date.now() - timesBeforeFetching, strategy: 'empty', } } else { diff --git a/packages/core/src/codewhisperer/util/telemetryHelper.ts b/packages/core/src/codewhisperer/util/telemetryHelper.ts index 58dc564a265..72f88ab9dc2 100644 --- a/packages/core/src/codewhisperer/util/telemetryHelper.ts +++ b/packages/core/src/codewhisperer/util/telemetryHelper.ts @@ -141,7 +141,7 @@ export class TelemetryHelper { ? this.timeSinceLastModification : undefined, codewhispererTimeSinceLastUserDecision: this.lastTriggerDecisionTime - ? performance.now() - this.lastTriggerDecisionTime + ? Date.now() - this.lastTriggerDecisionTime : undefined, codewhispererTimeToFirstRecommendation: session.timeToFirstRecommendation, codewhispererTriggerType: session.triggerType, @@ -355,7 +355,7 @@ export class TelemetryHelper { ? this.timeSinceLastModification : undefined, codewhispererTimeSinceLastUserDecision: this.lastTriggerDecisionTime - ? performance.now() - this.lastTriggerDecisionTime + ? Date.now() - this.lastTriggerDecisionTime : undefined, codewhispererTimeToFirstRecommendation: session.timeToFirstRecommendation, codewhispererTriggerCharacter: autoTriggerType === 'SpecialCharacters' ? this.triggerChar : undefined, @@ -366,7 +366,7 @@ export class TelemetryHelper { } telemetry.codewhisperer_userTriggerDecision.emit(aggregated) this.prevTriggerDecision = this.getAggregatedSuggestionState(this.sessionDecisions) - this.lastTriggerDecisionTime = performance.now() + this.lastTriggerDecisionTime = Date.now() // When we send a userTriggerDecision for neither Accept nor Reject, service side should not use this value // and client side will set this value to 0.0. @@ -429,7 +429,7 @@ export class TelemetryHelper { } public getLastTriggerDecisionForClassifier() { - if (this.lastTriggerDecisionTime && performance.now() - this.lastTriggerDecisionTime <= 2 * 60 * 1000) { + if (this.lastTriggerDecisionTime && Date.now() - this.lastTriggerDecisionTime <= 2 * 60 * 1000) { return this.prevTriggerDecision } } @@ -557,30 +557,30 @@ export class TelemetryHelper { if (session.preprocessEndTime !== 0) { getLogger().warn(`inline completion preprocessEndTime has been set and not reset correctly`) } - session.preprocessEndTime = performance.now() + session.preprocessEndTime = Date.now() } /** This method is assumed to be invoked first at the start of execution **/ public setInvokeSuggestionStartTime() { this.resetClientComponentLatencyTime() - session.invokeSuggestionStartTime = performance.now() + session.invokeSuggestionStartTime = Date.now() } public setSdkApiCallEndTime() { if (this._sdkApiCallEndTime === 0 && session.sdkApiCallStartTime !== 0) { - this._sdkApiCallEndTime = performance.now() + this._sdkApiCallEndTime = Date.now() } } public setAllPaginationEndTime() { if (this._allPaginationEndTime === 0 && this._sdkApiCallEndTime !== 0) { - this._allPaginationEndTime = performance.now() + this._allPaginationEndTime = Date.now() } } public setFirstSuggestionShowTime() { if (session.firstSuggestionShowTime === 0 && this._sdkApiCallEndTime !== 0) { - session.firstSuggestionShowTime = performance.now() + session.firstSuggestionShowTime = Date.now() } }