ankalagon / eta
用于计算进程进度和预计到达时间的库
1.0.3
2019-02-18 08:31 UTC
Requires
- php: >=7.1
This package is auto-updated.
Last update: 2024-09-18 21:40:24 UTC
README
该服务可以计算进程的进度和预计到达时间(ETA)
要求
- PHP7.1及以上
安装
更新您的composer.json文件并运行 composer update
{ "require": { "ankalagon/eta": "^1.0" } }
或者执行
composer require ankalagon/eta
用法
use Ankalagon\ETA\Eta; $eta = new Ankalagon\ETA\Eta($startTime, $allDataToProcess); //need to pass some time echo sprintf('Progress: %s%%, ETA: %s', $eta->getProgress(), $eta->getEta()).PHP_EOL;
示例脚本(在示例目录中)生成的输出
Progress: 0.04, ETA: 0h 08m 45s
Progress: 0.05, ETA: 0h 08m 45s
Progress: 0.05, ETA: 0h 08m 36s
Progress: 0.06, ETA: 0h 08m 28s
Progress: 0.07, ETA: 0h 08m 19s
Progress: 0.08, ETA: 0h 08m 12s
Progress: 0.09, ETA: 0h 08m 13s
Progress: 0.10, ETA: 0h 08m 10s
Progress: 0.11, ETA: 0h 08m 03s
Progress: 0.12, ETA: 0h 07m 59s
Progress: 0.13, ETA: 0h 07m 58s
Progress: 0.14, ETA: 0h 07m 56s
Progress: 0.15, ETA: 0h 07m 49s
Progress: 0.16, ETA: 0h 07m 43s
Progress: 0.16, ETA: 0h 07m 40s
Progress: 0.17, ETA: 0h 07m 38s
Progress: 0.18, ETA: 0h 07m 35s
Progress: 0.19, ETA: 0h 07m 31s
Progress: 0.20, ETA: 0h 07m 24s
Progress: 0.21, ETA: 0h 07m 20s