forked from Kotlin/kotlinx.coroutines
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* New selects are twice as fast as the previous version * The implementation doesn't require an NCAS protocol by giving up lock-freedom and linearizability in corner cases * The overall algorithm is much more straightforward and easier to maintain Co-authored-by: Nikita Koval <[email protected]>
- Loading branch information
Showing
43 changed files
with
2,334 additions
and
1,635 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
benchmarks/src/jmh/kotlin/benchmarks/tailcall/SelectBenchmark.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright 2016-2022 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. | ||
*/ | ||
|
||
package benchmarks.tailcall | ||
|
||
import kotlinx.coroutines.* | ||
import kotlinx.coroutines.channels.* | ||
import kotlinx.coroutines.selects.* | ||
import org.openjdk.jmh.annotations.* | ||
import java.util.concurrent.* | ||
|
||
@Warmup(iterations = 8, time = 1, timeUnit = TimeUnit.SECONDS) | ||
@Measurement(iterations = 8, time = 1, timeUnit = TimeUnit.SECONDS) | ||
@Fork(value = 1) | ||
@BenchmarkMode(Mode.AverageTime) | ||
@OutputTimeUnit(TimeUnit.MICROSECONDS) | ||
@State(Scope.Benchmark) | ||
open class SelectBenchmark { | ||
// 450 | ||
private val iterations = 1000 | ||
|
||
@Benchmark | ||
fun stressSelect() = runBlocking { | ||
val pingPong = Channel<Unit>() | ||
launch { | ||
repeat(iterations) { | ||
select { | ||
pingPong.onSend(Unit) {} | ||
} | ||
} | ||
} | ||
|
||
launch { | ||
repeat(iterations) { | ||
select { | ||
pingPong.onReceive() {} | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.