File tree Expand file tree Collapse file tree 2 files changed +15
-6
lines changed
utbot-core/src/main/kotlin/org/utbot/common
utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/agent Expand file tree Collapse file tree 2 files changed +15
-6
lines changed Original file line number Diff line number Diff line change @@ -28,12 +28,19 @@ class StopWatch {
28
28
startTime = System .currentTimeMillis()
29
29
}
30
30
}
31
-
32
- fun stop () {
31
+
32
+ /* *
33
+ * @param compensationMillis the duration in millis that should be subtracted from [elapsedMillis] to compensate
34
+ * for stopping and restarting [StopWatch] taking some time, can also be used to compensate for some activities,
35
+ * that are hard to directly detect (e.g. class loading).
36
+ *
37
+ * NOTE: [compensationMillis] will never cause [elapsedMillis] become negative.
38
+ */
39
+ fun stop (compensationMillis : Long = 0) {
33
40
lock.withLockInterruptibly {
34
- startTime?.let {
35
- elapsedMillis + = (System .currentTimeMillis() - it )
36
- startTime = null
41
+ startTime?.let { startTime ->
42
+ elapsedMillis + = (( System .currentTimeMillis() - startTime) - compensationMillis).coerceAtLeast( 0 )
43
+ this . startTime = null
37
44
}
38
45
}
39
46
}
Original file line number Diff line number Diff line change @@ -35,7 +35,9 @@ class DynamicClassTransformer : ClassFileTransformer {
35
35
classfileBuffer : ByteArray
36
36
): ByteArray? {
37
37
try {
38
- UtContext .currentContext()?.stopWatch?.stop()
38
+ // since we got here we have loaded a new class, meaning program is not stuck and some "meaningful"
39
+ // non-repeating actions are performed, so we assume that we should not time out for then next 65 ms
40
+ UtContext .currentContext()?.stopWatch?.stop(compensationMillis = 65 )
39
41
val pathToClassfile = protectionDomain.codeSource?.location?.toURI()?.let (Paths ::get)?.absolutePathString()
40
42
return if (pathToClassfile in pathsToUserClasses ||
41
43
packsToAlwaysTransform.any(className::startsWith)
You can’t perform that action at this time.
0 commit comments