1
1
package org.utbot.benchmarks
2
2
3
- import org.junit.jupiter.api.RepeatedTest
4
3
import org.openjdk.jmh.annotations.Benchmark
5
4
import org.openjdk.jmh.annotations.Fork
6
5
import org.openjdk.jmh.annotations.Measurement
@@ -10,26 +9,37 @@ import org.openjdk.jmh.annotations.State
10
9
import org.openjdk.jmh.annotations.Threads
11
10
import org.openjdk.jmh.annotations.Warmup
12
11
import org.utbot.common.FileUtil
13
- import org.utbot.framework.plugin.api.TestCaseGenerator
12
+ import org.utbot.examples.strings11.StringConcat
13
+ import org.utbot.framework.UtSettings
14
+ import org.utbot.framework.plugin.api.MockStrategyApi
15
+ import org.utbot.framework.plugin.api.util.UtContext
16
+ import org.utbot.framework.plugin.api.util.executableId
17
+ import org.utbot.framework.plugin.api.util.withUtContext
14
18
import org.utbot.framework.plugin.services.JdkInfoDefaultProvider
15
19
import org.utbot.framework.util.SootUtils
16
20
import org.utbot.tests.infrastructure.TestSpecificTestCaseGenerator
17
- import org.utbot.tests.infrastructure.UtValueTestCaseChecker
18
- import org.utbot.tests.infrastructure.ignoreExecutionsNumber
19
21
import java.util.concurrent.TimeUnit
20
22
21
23
@State(Scope .Benchmark )
22
24
@Fork(1 )
23
25
@Threads(1 )
24
- @Warmup(iterations = 3 )
25
- @Measurement(iterations = 5 , timeUnit = TimeUnit .SECONDS )
26
- class BenchmarksTest : UtValueTestCaseChecker (
27
- Benchmarks : :class,
28
- ) {
29
- lateinit var testCaseGenerator : TestCaseGenerator
26
+ @Warmup(iterations = 2 )
27
+ @Measurement(iterations = 4 , timeUnit = TimeUnit .SECONDS )
28
+ class BenchmarksTest {
29
+ lateinit var testCaseGenerator : TestSpecificTestCaseGenerator
30
+ lateinit var context : UtContext
31
+
30
32
@Setup
31
33
fun setUp () {
34
+ UtSettings .utBotGenerationTimeoutInMillis = 200_000
35
+ UtSettings .useFuzzing = false
36
+ UtSettings .useConcreteExecution = false
37
+
32
38
val testClass = Benchmarks ::class .java
39
+
40
+ context = UtContext (testClass.classLoader)
41
+ UtContext .setUtContext(context)
42
+
33
43
SootUtils .runSoot(Benchmarks ::class .java, true , JdkInfoDefaultProvider ().info)
34
44
testCaseGenerator = TestSpecificTestCaseGenerator (
35
45
FileUtil .locateClassPath(testClass)!! .toPath(),
@@ -41,22 +51,52 @@ class BenchmarksTest : UtValueTestCaseChecker(
41
51
42
52
@Benchmark
43
53
fun benchmarkLongMethod () {
44
- check(
45
- Benchmarks ::longMethod,
46
- ignoreExecutionsNumber ,
47
- { x, y, r -> r == 1 },
48
- { x, y, r -> r == 2 },
49
- )
54
+ withUtContext(context) {
55
+ testCaseGenerator.generate(
56
+ Benchmarks ::longMethod.executableId ,
57
+ MockStrategyApi . NO_MOCKS
58
+ )
59
+ }
50
60
}
51
61
52
62
53
63
@Benchmark
54
64
fun benchmarkCycle () {
55
- check(
56
- Benchmarks ::cycle,
57
- ignoreExecutionsNumber,
58
- { _, r -> r == 1 },
59
- { _, r -> r == 2 },
60
- )
65
+ withUtContext(context) {
66
+ testCaseGenerator.generate(
67
+ Benchmarks ::cycle.executableId,
68
+ MockStrategyApi .NO_MOCKS
69
+ )
70
+ }
71
+ }
72
+
73
+ @Benchmark
74
+ fun benchmarkExceptionInToString () {
75
+ withUtContext(context) {
76
+ testCaseGenerator.generate(
77
+ StringConcat ::exceptionInToString.executableId,
78
+ MockStrategyApi .NO_MOCKS
79
+ )
80
+ }
81
+ }
82
+
83
+ @Benchmark
84
+ fun benchmarkPutAndGet () {
85
+ withUtContext(context) {
86
+ testCaseGenerator.generate(
87
+ Benchmarks ::mapPutAndGet.executableId,
88
+ MockStrategyApi .NO_MOCKS
89
+ )
90
+ }
91
+ }
92
+
93
+ @Benchmark
94
+ fun benchmarkPutInMapFromParameters () {
95
+ withUtContext(context) {
96
+ testCaseGenerator.generate(
97
+ Benchmarks ::putInMapFromParameters.executableId,
98
+ MockStrategyApi .NO_MOCKS
99
+ )
100
+ }
61
101
}
62
102
}
0 commit comments