Skip to content

Instantly share code, notes, and snippets.

@soudmaijer
Last active April 28, 2021 07:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save soudmaijer/f29a1b49f64ede858d46e9ad3737bfdf to your computer and use it in GitHub Desktop.
Save soudmaijer/f29a1b49f64ede858d46e9ad3737bfdf to your computer and use it in GitHub Desktop.
import kotlinx.coroutines.delay
import kotlinx.coroutines.runBlocking
import kotlin.system.measureTimeMillis
suspend fun loadImage(name: String) {
println("Loading image: $name...")
delay(2000) // simulate slow behaviour
println("Done loading image: $name.")
}
fun main() {
runBlocking {
val time = measureTimeMillis {
loadImage("image1")
loadImage("image2")
}
println("Loading images took: $time ms.")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment