Last active
March 26, 2020 17:47
-
-
Save anacicconi/89bb2d1f04dc992e7c9e43098e99bb8f to your computer and use it in GitHub Desktop.
Comparison Coroutines versus RX
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
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