-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
62 additions
and
19 deletions.
There are no files selected for viewing
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
2 changes: 2 additions & 0 deletions
2
evas/src/commonBenchmark/kotlin/io/sellmair/evas/benchmark/events/CreateFlowBenchmark.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,2 @@ | ||
package io.sellmair.evas.benchmark.events | ||
|
38 changes: 38 additions & 0 deletions
38
evas/src/commonBenchmark/kotlin/io/sellmair/evas/benchmark/utils/AtomicSnapshotBenchmark.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,38 @@ | ||
package io.sellmair.evas.benchmark.utils | ||
|
||
import io.sellmair.evas.AtomicSnapshotList | ||
import kotlinx.benchmark.* | ||
|
||
@BenchmarkMode(Mode.AverageTime) | ||
@OutputTimeUnit(BenchmarkTimeUnit.NANOSECONDS) | ||
@Warmup(iterations = 10, time = 500, timeUnit = BenchmarkTimeUnit.MILLISECONDS) | ||
@Measurement(iterations = 20, time = 1, timeUnit = BenchmarkTimeUnit.SECONDS) | ||
@State(Scope.Benchmark) | ||
open class AtomicSnapshotBenchmark { | ||
|
||
private var atomicList = AtomicSnapshotList<Int>() | ||
|
||
@Setup | ||
fun setup() { | ||
atomicList = AtomicSnapshotList() | ||
} | ||
|
||
/** | ||
* jvmBenchmark summary: | ||
* Benchmark Mode Cnt Score Error Units | ||
* AtomicSnapshotBenchmark.writeReadWrite avgt 20 23.781 ± 0.127 ns/op | ||
* | ||
* macosArm64Benchmark summary: | ||
* Benchmark Mode Cnt Score Error Units | ||
* CreateFlowBenchmark.appendList avgt 20 158.378 ± 0.612 ns/op | ||
*/ | ||
@Benchmark | ||
fun writeReadWrite(): Int { | ||
atomicList.write { it.add(42) } | ||
try { | ||
return atomicList.snapshot().size | ||
} finally { | ||
atomicList.write { it.clear() } | ||
} | ||
} | ||
} |
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