如何知道sftp文件传输速度和所用时间

时间:2015-12-08 11:10:39

标签: php sftp phpseclib net-sftp ssh2-sftp

有没有办法计算所花费的时间&在PHP中通过sftp下载/上传文件的速度与下面类似?

$sftp->get('filename', 'local/filename'); //gets the file
$sftp->size('filename'); //gives the size of the file.

这两个命令获取文件&给出了尺寸......这样我们就可以计算速度和速度。时间?

1 个答案:

答案 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);