Can anyone please let me know how I can properly calculate the download speed like Ookla speed tester.
I have tried to calculate it with the following approach but still not getting the correct result.
I am downloading a file from CDN
and calculate the time it takes to download the complete file. Then divide it.
for e.g.:
- open a connection with
URL
- var starting time in milliseconds.
- download the file
var endTime
in millisecondsSpeed = (downloadSize in bits) / ((endTime-Startime)/1000)