Skip to content

Instantly share code, notes, and snippets.

@nihsmik
Created December 28, 2020 09:24
Show Gist options
  • Save nihsmik/550f389937674331ee0f0a01e107fe7d to your computer and use it in GitHub Desktop.
Save nihsmik/550f389937674331ee0f0a01e107fe7d to your computer and use it in GitHub Desktop.
Kotlin Performance Test: Iterable<T>.map
import kotlin.time.Duration
import kotlin.time.measureTime
fun main() {
val durations = mutableListOf<Duration>()
repeat(10) {
val duration = measureTime { (0..1_000_000).map { it + 1 } }
durations += duration
}
println(durations)
// [53.2ms, 66.2ms, 53.4ms, 14.5ms, 54.1ms, 17.2ms, 80.3ms, 96.9ms, 17.0ms, 35.9ms]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment