-1

sftp有没有一种方法可以计算通过php下载/上传文件所需的时间和速度,如下所示?

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

这两个命令获取文件并给出大小..这样我们可以计算速度和时间吗?

4

1 回答 1

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);
于 2015-12-08T11:17:00.187 回答