@@ -47,7 +47,6 @@ import org.utbot.fuzzer.UtFuzzedExecution
47
47
import org.utbot.summary.usvm.summarizeAll
48
48
import java.io.File
49
49
import java.net.URLClassLoader
50
- import kotlin.system.measureTimeMillis
51
50
import kotlin.time.Duration.Companion.milliseconds
52
51
53
52
private val logger = KotlinLogging .logger {}
@@ -168,7 +167,7 @@ fun runUsvmGeneration(
168
167
methods = jcMethods,
169
168
targets = emptyList()
170
169
) { state ->
171
- val jcExecution = accumulateMeasureTime(" executor.execute(${cut.classId.name} )" , timeStats) {
170
+ val jcExecution = accumulateMeasureTime(" executor.execute(${cut.classId.name} )" , timeStats, state.entrypoint ) {
172
171
runCatching {
173
172
executor.execute(state.entrypoint.typedMethod, state)
174
173
}.getOrElse { e ->
@@ -177,7 +176,7 @@ fun runUsvmGeneration(
177
176
}
178
177
}
179
178
val methodId = jcExecution.method.method.toExecutableId(jcContainer.cp)
180
- val utExecution = accumulateMeasureTime(" JcToUtExecutionConverter.convert(${cut.classId.name} )" , timeStats) {
179
+ val utExecution = accumulateMeasureTime(" JcToUtExecutionConverter.convert(${cut.classId.name} )" , timeStats, jcExecution.method.method ) {
181
180
runCatching {
182
181
JcToUtExecutionConverter (
183
182
jcExecution = jcExecution,
@@ -281,14 +280,20 @@ fun JcMachine.analyzeAsync(
281
280
} ? : logger.error { " analyzeAsync time exceeded hard time out" }
282
281
}
283
282
284
- inline fun <T > accumulateMeasureTime (
283
+ private inline fun <T > accumulateMeasureTime (
285
284
regionName : String ,
286
285
timeAccumulatorMillis : MutableMap <String , Long >,
286
+ warnData : Any? ,
287
+ millisWarnThreshold : Long = 2_000,
287
288
block : () -> T
288
289
): T {
289
- var res: T
290
- timeAccumulatorMillis[regionName] = (timeAccumulatorMillis[regionName] ? : 0 ) + measureTimeMillis {
291
- res = block()
290
+ val millisBefore = System .currentTimeMillis()
291
+ try {
292
+ return block()
293
+ } finally {
294
+ val millisTaken = System .currentTimeMillis() - millisBefore
295
+ if (millisTaken > millisWarnThreshold)
296
+ logger.warn(" Spent $millisTaken ms on region [$regionName ] for [$warnData ]" )
297
+ timeAccumulatorMillis[regionName] = (timeAccumulatorMillis[regionName] ? : 0 ) + millisTaken
292
298
}
293
- return res
294
299
}
0 commit comments