Created
June 30, 2024 11:10
-
-
Save sajjadyousefnia/65262699f02c204b253cfba04b9f860f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun calculateDownloadSpeed( | |
oldBytes: Long, newBytes: Long, oldTimeMillis: Long, newTimeMillis: Long | |
): Double { | |
val downloadedBytes = newBytes - oldBytes | |
val timeSeconds = (newTimeMillis - oldTimeMillis) / 1000.0 | |
val speedBytesPerSecond = downloadedBytes / timeSeconds | |
return speedBytesPerSecond / 1_048_576 // Convert to megabytes per second | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment