File tree 1 file changed +42
-0
lines changed
benchmarks/src/jmh/kotlin/benchmarks/tailcall
1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright 2016-2022 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
3
+ */
4
+
5
+ package benchmarks.tailcall
6
+
7
+ import kotlinx.coroutines.*
8
+ import kotlinx.coroutines.channels.*
9
+ import kotlinx.coroutines.selects.*
10
+ import org.openjdk.jmh.annotations.*
11
+ import java.util.concurrent.*
12
+
13
+ @Warmup(iterations = 8 , time = 1 , timeUnit = TimeUnit .SECONDS )
14
+ @Measurement(iterations = 8 , time = 1 , timeUnit = TimeUnit .SECONDS )
15
+ @Fork(value = 1 )
16
+ @BenchmarkMode(Mode .AverageTime )
17
+ @OutputTimeUnit(TimeUnit .MICROSECONDS )
18
+ @State(Scope .Benchmark )
19
+ open class SelectBenchmark {
20
+ // 450
21
+ private val iterations = 1000
22
+
23
+ @Benchmark
24
+ fun stressSelect () = runBlocking {
25
+ val pingPong = Channel <Unit >()
26
+ launch {
27
+ repeat(iterations) {
28
+ select {
29
+ pingPong.onSend(Unit ) {}
30
+ }
31
+ }
32
+ }
33
+
34
+ launch {
35
+ repeat(iterations) {
36
+ select {
37
+ pingPong.onReceive() {}
38
+ }
39
+ }
40
+ }
41
+ }
42
+ }
You can’t perform that action at this time.
0 commit comments