<?php

$mBaseURL = 'http://www.infosys.rs/speedtest/';

$mTimeStart = microtime(true);
$mData = file_get_contents($mBaseURL . 'speedtest.php?downloadtest=10000');
//$mTimeElapsed = (microtime(true) - $mTimeStart) * 0.000001; // vreme u sekundama
$mTimeElapsed = (microtime(true) - $mTimeStart) ; // vreme u mikrosekundama
echo "TimeElapsed: $mTimeElapsed<br>";

$mDataLength = strlen ($mData);
echo "DataLength: $mDataLength<br>";

//$mSpeedBytesSecond = $mDataLength / (1 / $mTimeElapsed);
$mSpeedBytesSecond = $mDataLength / $mTimeElapsed;

$mSpeedMBPS = ($mSpeedBytesSecond / 1024 / 1024) * 8;

//echo "SpeedBytesSecond: $mSpeedBytesSecond<br>";
//echo "SpeedKBytesSecond: " . $mSpeedBytesSecond/1024 . "<br>";
//echo "SpeedMBytesSecond: " . $mSpeedBytesSecond/1024/1024 . "<br>";
echo "Speed: " . $mSpeedMBPS . " mbps<br>";

//echo $mData;

?>