Android Studio Network Profiler fluctuating throughput-ThrowExceptions

Exception or error:

Does anybody know why I get such fluctuations on my network throughput when i check with AS Network Profiler? It always has the same schema like this:

enter image description here

I try to play with setReceiveBufferSize and different buffer sizes but always have the schema like in the picture. My main concern is that i try to measure the throughput but the peaks and troughs will make it hard. In the best case i need something like a burst to get the maximum throughput. Here is a little snippet how i try to read the bytes with URLConnection

private fun download() {
    val url = URL("http://someurl/file.bin")
    val urlConnection: URLConnection = url.openConnection()
    val byteArray = ByteArray(262144)
    val bufferedInputStream = BufferedInputStream(urlConnection.getInputStream(), 262144)
    while(true) {
        val read =
How to solve:

Leave a Reply

Your email address will not be published. Required fields are marked *