This is the suspend version of the same, which is ...
# arrow
g
This is the suspend version of the same, which is FASTER
Copy code
@Test
    fun `parTraverse + suspending`() {
        val time = measureTimeMillis {
            runBlocking {
                (1..20).parTraverse {
                    suspendingWork(it)
                }
            }
        }
        // 1s, multiple unblocked bg threads
        println("Done in $time ms [${Thread.currentThread().name}]")
    }

private suspend fun suspendingWork(i: Int) {
        delay(1000)
        println("Work $i done [${Thread.currentThread().name}]")
    }