Is anyone downloading/streaming large files throug...
# ktor
s
Is anyone downloading/streaming large files through ktor in their project? I’m noticing that ktor is performing 5-8x slower on native than jvm. I’ll most likely be forced to remove ktor in favor of expect/actual but I’m really trying to avoid that. Here’s a sample code to test this:
Copy code
val fileUrl = "<https://file-examples-com.github.io/uploads/2017/04/file_example_MP4_1920_18MG.mp4>"
client.get<HttpStatement>(fileUrl).execute { response ->
  val channel = response.receive<ByteReadChannel>()
  val time = measureTime {
    while (!channel.isClosedForRead) {
      val packet = channel.readRemaining(limit = 4_096)
      while (!packet.isEmpty) {
        packet.readBytes()
      }
    }
  }
  println("Streamed file in $time")
}
FWIW I’m using ktor 1.6.1 with
ktor-client-ios
on native and
ktor-client-okhttp
on jvm.
123 Views