Skip to content

Instantly share code, notes, and snippets.

@anacicconi
Last active March 26, 2020 17:47
Show Gist options
  • Save anacicconi/89bb2d1f04dc992e7c9e43098e99bb8f to your computer and use it in GitHub Desktop.
Save anacicconi/89bb2d1f04dc992e7c9e43098e99bb8f to your computer and use it in GitHub Desktop.
Comparison Coroutines versus RX
fun main() {
runBlocking {
val timeCoroutine = measureTimeMillis {
(1..10).asFlow()
.map { "value $it" }
.collect {
println(it)
}
}
println("Coroutine took $timeCoroutine ms")
}
val timeRx = measureTimeMillis {
Observable.fromIterable((1..10))
.map { "value $it" }
.blockingSubscribe {
println(it)
}
}
println("RX took $timeRx ms")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment