Adam Brown
02/12/2024, 11:38 PMAdam Brown
02/13/2024, 12:50 AMmohamed rejeb
02/13/2024, 6:24 AMArjan van Wieringen
02/13/2024, 6:52 AMOleksandr Karpovich [JB]
02/13/2024, 11:25 AMreadResourceBytes
is a suspend fun, under the hood it makes fetch (browser runs it in a worker).
so 2 fetch requests do not block the thread.
But depending on the size of those files and the applied processing after the fetch, it might take some time.
yes, it's single threaded. Heavy processing better to run in a worker. (fetch + strings processing) And then to post the result back so Compose can use it.Adam Brown
02/14/2024, 12:50 AMAdam Brown
02/14/2024, 12:51 AMArjan van Wieringen
02/14/2024, 6:40 AMOleksandr Karpovich [JB]
02/14/2024, 4:42 PMyield()
from time to time in the loops (in fastForEach).
But I'm not sure what part is the most heavy. If it's not the loop, but decodeToString or splitLines, then not sure where to put yield
.
Also to reduce the total waiting time, I think it might worth to make parallel fetch requests (currently they're consequent - readResourceBytes). scope.launch(Dispatchers.Default) { ... }
Adam Brown
02/15/2024, 12:39 AMAdam Brown
02/15/2024, 12:40 AMsplitLines
is probably causing a full re-allocation of the input? I'm guessing here, but it's probably not acting like a stream.