File tree Expand file tree Collapse file tree 2 files changed +13
-13
lines changed
examples/kotlin-multiplatform/src/commonMain/kotlin
integration/src/test/resources/templates/kotlin-multiplatform/src/commonMain/kotlin Expand file tree Collapse file tree 2 files changed +13
-13
lines changed Original file line number Diff line number Diff line change @@ -8,27 +8,30 @@ import kotlin.math.*
8
8
@OutputTimeUnit(BenchmarkTimeUnit .MILLISECONDS )
9
9
@BenchmarkMode(Mode .Throughput )
10
10
class ParamBenchmark {
11
-
11
+
12
12
@Param(" 1" , " 2" )
13
13
var data = 0
14
14
15
15
@Param(" 1" , " 2" )
16
16
var value = 0
17
-
18
- private lateinit var text : String
19
-
20
- @Setup
21
- fun setUp () {
22
- text = " Hello!"
23
- }
24
-
17
+
18
+ @Param(""" a "string" with quotes""" )
19
+ var text: String = " "
20
+
25
21
@Benchmark
26
22
fun mathBenchmark (): Double {
27
23
return log(sqrt(data.toDouble()) * data, 2.0 )
28
24
}
29
-
25
+
30
26
@Benchmark
31
27
fun otherBenchmark (): Int {
32
28
return data + data
33
29
}
30
+
31
+ @Benchmark
32
+ fun textContentCheck (): String {
33
+ check(text.length == 22 )
34
+ check(text.count { it == ' \" ' } == 2 )
35
+ return text
36
+ }
34
37
}
Original file line number Diff line number Diff line change @@ -8,9 +8,6 @@ import kotlin.math.*
8
8
@OutputTimeUnit(BenchmarkTimeUnit .MILLISECONDS )
9
9
@BenchmarkMode(Mode .Throughput )
10
10
open class CommonBenchmark {
11
- @Param(""" a "string" with quotes""" )
12
- var value = " "
13
-
14
11
@Benchmark
15
12
open fun mathBenchmark (): Double {
16
13
return log(sqrt(3.0 ) * cos(3.0 ), 2.0 )
You can’t perform that action at this time.
0 commit comments