Created
December 28, 2020 09:25
-
-
Save nihsmik/8e8ac593b5a2607f116a8eccf0de9be9 to your computer and use it in GitHub Desktop.
Kotlin Performance Test: Iterable<T>.forEach
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
import kotlin.time.Duration | |
import kotlin.time.measureTime | |
fun main() { | |
val durations = mutableListOf<Duration>() | |
repeat(10) { | |
val duration = measureTime { (0..1_000_000).forEach { it + 1 } } | |
durations += duration | |
} | |
println(durations) | |
// [14.0ms, 7.96ms, 1.68ms, 1.70ms, 1.71ms, 1.86ms, 1.68ms, 1.68ms, 1.71ms, 1.74ms] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment