mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IJPL-162853 use kotlin function for measuring time
GitOrigin-RevId: 99b8ed9cf7d57704bb60a873db409646bafda817
This commit is contained in:
committed by
intellij-monorepo-bot
parent
134be56b0a
commit
e3cfcff5a7
+5
-5
@@ -17,6 +17,7 @@ import org.jetbrains.annotations.Nls
|
||||
import org.jetbrains.annotations.NonNls
|
||||
import kotlin.math.abs
|
||||
import kotlin.math.max
|
||||
import kotlin.time.measureTimedValue
|
||||
|
||||
internal class ParsingTreeBuilder(
|
||||
val lexer: Lexer,
|
||||
@@ -534,11 +535,10 @@ private fun performLexing(
|
||||
return LexingResult(cachedLexemes, 0)
|
||||
}
|
||||
// todo do we need to cover a raw TokenList?
|
||||
|
||||
val startTime = System.nanoTime()
|
||||
val sequence = performLexing(text, lexer, cancellationProvider, logger) as TokenSequence
|
||||
val endTime = System.nanoTime()
|
||||
return LexingResult(sequence, endTime - startTime)
|
||||
val (sequence, duration) = measureTimedValue {
|
||||
performLexing(text, lexer, cancellationProvider, logger) as TokenSequence
|
||||
}
|
||||
return LexingResult(sequence, duration.inWholeNanoseconds)
|
||||
}
|
||||
|
||||
private data class LexingResult(val tokens: TokenSequence, val lexingTimeNs: Long)
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.intellij.platform.syntax.Logger
|
||||
import org.jetbrains.annotations.NonNls
|
||||
import kotlin.math.max
|
||||
import kotlin.math.min
|
||||
import kotlin.time.measureTimedValue
|
||||
|
||||
internal class TokenSequence(
|
||||
internal val lexStarts: IntArray,
|
||||
@@ -67,9 +68,10 @@ internal class TokenListLexerImpl(
|
||||
return
|
||||
}
|
||||
|
||||
val start = System.currentTimeMillis()
|
||||
start(buffer, startOffset, endOffset, initialState)
|
||||
val startDuration = System.currentTimeMillis() - start
|
||||
val (_, duration) = measureTimedValue {
|
||||
start(buffer, startOffset, endOffset, initialState)
|
||||
}
|
||||
val startDuration = duration.inWholeNanoseconds
|
||||
if (startDuration > LEXER_START_THRESHOLD) {
|
||||
logger.debug("Starting lexer took: $startDuration; at $startOffset - $endOffset; state: $initialState; text: ${buffer.shortenTextWithEllipsis(1024, 500)}")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user