I am looking for an opportunity to check the connection speed with the user. It is assumed that it will be saved as cookies and javascript, as well as css files will be adapted if the speed is slow.
The ability to check the speed that I currently have is as follows
$kb = 512;
flush();
echo "<!-";
$time = explode(" ",microtime());
for($x=0;$x<$kb;$x++){
echo str_pad('', 512, '.');
flush();
}
$time_end = explode(" ",microtime());
echo "->";
$start = $time[0] + $time[1];
$finish = $time_end[0] + $time_end[1];
$deltat = $finish - $start;
return round($kb / $deltat, 3);
While it works, I do not like to insert so many codes into my code, and if I repeat all this, I can not save the result in a cookie, because there was already an exit.
Is it possible to do something like this in another file? Do you have a solution?
Thanks in advance.
source
share