有没有办法计算所花费的时间&在PHP中通过sftp
下载/上传文件的速度与下面类似?
$sftp->get('filename', 'local/filename'); //gets the file
$sftp->size('filename'); //gives the size of the file.
这两个命令获取文件&给出了尺寸......这样我们就可以计算速度和速度。时间?
答案 0 :(得分:1)
当然,您可以获得所需的所有数据:时间和大小。
$start = time();
$sftp->get('filename', 'local/filename'); //gets the file
$size = $sftp->size('filename'); //gives the size of the file.
$timeTakenInSeconds = time() - $start;
echo sprintf('Bytes/second: %d', $size / $timeTakenInSeconds);