https://kotlinlang.org logo
#coroutines
Title
# coroutines
o

Oleh Ponomarenko

03/15/2019, 11:08 AM
Have you ever seen some analytic of launching some jobs in different Dispatchers (Main, Default, IO)? I know the difference between these dispatchers. I'm just interested in comparable data.
a

ahulyk

03/15/2019, 12:33 PM
It depends on what you going to achieve.
o

Oleh Ponomarenko

03/15/2019, 12:34 PM
I want to compare performance of this coroutines.
If I run the same task in each of the coroutines, what would be the difference in time
And I'm wondering how it would work on different devices (different amount of core)
g

gildor

03/15/2019, 12:46 PM
Default and IO use the same shared pool of threads, so I don't think that there is any difference
Main uses different scheduling mechanism (on Android it uses Handler to schedule coroutine invocation), so it may be at some point different, but still don't understand what kind performance characteristic is important for you
Because you said about different about of cores, but how this related to task performance? It's more about single core performance and how many parallel tasks you can run and how efficient it will be
So in general I think this is not something coroutines specific and has too many factors to measure it properly
Also, because each of mentioned dispatchers has own use case not sure that it make sense to compare them at all
For example if invoking on Main thread for some reason somehow faster or slower what does it change for you? You anyway cannot block it and use for any blocking IO or CPU intensive task
o

Oleh Ponomarenko

03/15/2019, 2:17 PM
What time will be taken for the same huge task (without UI) in IO, Default and Unconfined dispatchers?
g

gildor

03/16/2019, 2:06 AM
A task that does what?
You added Unconfined to comparasion, but this dispatcher doesn't have any own threads, just run coroutine on your current thread
2 Views