How can I create a PHP page that will detect the user's internet speed and show it on the page? Something like,
Your internet speed is ??? Kbps
By user uploading a file to your server. Then you divide file size in kb with time passed in seconds. You then get kb/s (upload speed).
According to the Federal Communications Commission (FCC), a good internet speed is at or above 25 Mbps. These speeds will support most online activity, such as HD streaming, online gaming, web browsing and downloading music.
Start testing your speed in seconds by using the Begin Test button on the front page map. This will find a server near you, and test the ping, download speed, and upload speed of your Internet connection.
To use Web Speed, visit the URL of the website that you would like to measure. Open the Speedtest Chrome Extension after or while the website you are visiting loads. The website's Web Speed, as measured in seconds, will appear in the Speedtest Chrome Extension window.
This might not be completely what you're looking for (read the bold part), but I doubt if anything else is possible.
This script sends 512 KB of HTML comments to your client. Parsing that HTML may add to the total transfer time, so don't take this as your raw download speed.
Quoted from: PHP Speed test
Source is here:
http://jan.moesen.nu/code/php/speedtest/index.php?source=1
Hope that helps.
<?php
$kb=1024;
echo "streaming $kb Kb...<!-";
flush();
$time = explode(" ",microtime());
$start = $time[0] + $time[1];
for($x=0;$x<$kb;$x++){
echo str_pad('', 1024, '.');
flush();
}
$time = explode(" ",microtime());
$finish = $time[0] + $time[1];
$deltat = $finish - $start;
echo "-> Test finished in $deltat seconds. Your speed is ". round($kb / $deltat, 3)."Kb/s";
?>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With