Skip to content

Commit 3f2542d

Browse files
committed
measureTimedValue
1 parent e29a079 commit 3f2542d

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/util/CodeWhispererFileContextProvider.kt

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import java.io.DataInput
4343
import java.io.DataOutput
4444
import java.util.Collections
4545
import kotlin.coroutines.coroutineContext
46+
import kotlin.time.measureTimedValue
4647

4748
private val contentRootPathProvider = CopyContentRootPathProvider()
4849

@@ -227,12 +228,11 @@ class DefaultCodeWhispererFileContextProvider(private val project: Project) : Fi
227228

228229
val contexts = withContext(coroutineContext) {
229230
val projectContextDeferred1 = async {
230-
val t0 = System.currentTimeMillis()
231-
val codemapContext = fetchProjectContext(query, psiFile, targetContext)
232-
val t1 = System.currentTimeMillis()
231+
val timedCodemapContext = measureTimedValue { fetchProjectContext(query, psiFile, targetContext) }
232+
val codemapContext = timedCodemapContext.value
233233
LOG.debug {
234234
buildString {
235-
append("time elapse for fetching project context=${t1 - t0}ms; ")
235+
append("time elapse for fetching project context=${timedCodemapContext.duration.inWholeMilliseconds}ms; ")
236236
append("numberOfChunks=${codemapContext.contents.size}; ")
237237
append("totalLength=${codemapContext.contentLength}")
238238
}
@@ -242,12 +242,11 @@ class DefaultCodeWhispererFileContextProvider(private val project: Project) : Fi
242242
}
243243

244244
val openTabsContextDeferred1 = async {
245-
val t0 = System.currentTimeMillis()
246-
val opentabContext = fetchOpenTabsContext(query, psiFile, targetContext)
247-
val t1 = System.currentTimeMillis()
245+
val timedOpentabContext = measureTimedValue { fetchOpenTabsContext(query, psiFile, targetContext) }
246+
val opentabContext = timedOpentabContext.value
248247
LOG.debug {
249248
buildString {
250-
append("time elapse for open tabs context=${t1 - t0}ms; ")
249+
append("time elapse for open tabs context=${timedOpentabContext.duration.inWholeMilliseconds}ms; ")
251250
append("numberOfChunks=${opentabContext.contents.size}; ")
252251
append("totalLength=${opentabContext.contentLength}")
253252
}

0 commit comments

Comments
 (0)