I am trying to calculate the internet speed but I get a small value. This is the code:
useEffect(() => var imageAddr = "../../img/noventi-logo.png" +"?n=" + Math.random(); var startTime: number, endTime; var downloadSize = 200000; var download = new Image(); startTime = (new Date()).getTime(); download.src = imageAddr; window.setTimeout( download.onload = function () { endTime = (new Date()).getTime(); showResults(endTime, startTime, downloadSize); }, 1);,[]) function showResults(endTime: number, startTime: number, downloadSize: number) { var duration = (endTime - startTime) / 1000; var bitsLoaded = downloadSize * 8; var speedBps: any = (bitsLoaded / duration).toFixed(2); var speedKbps: any = (speedBps / 1024).toFixed(2); var speedMbps = (speedKbps / 1024).toFixed(2); alert("Your connection speed is: \n" + speedBps +" bps\n" + speedKbps +" kbps\n" + speedMbps +" Mbps\n" );}
And as a result I get only values like 0,6 Mbps.
PLEASE HELP ME