markuszeller/php-timer
Composer 安装命令:
composer require markuszeller/php-timer
包简介
Simple Timer Class
README 文档
README
Simple Timer Class
Init a timer
$timer = new Timer();
Do something what takes some time and stop the timer.
$timer->stop();
Assuming the timer took 66.6 seconds for the do-something operations.
Receive the values in different formats:
-
Fractioned with 2 decimals
// 66.60 echo $timer->getSecondsFractioned(); -
Rounded as an integer
// 67 echo $timer->getSecondsRounded(); -
Formatted as time hh:mm:ss
// 00:01:06 echo $timer->getTimeFormatted(); -
Formatted as milliseconds
// 5000.1788139343 sleep(5); echo $timer->getMilliseconds(); -
Different outputs
$timer->setTotal(100);
$timer->setDone(88);
// █████████████████░░░
// 20 chars are default
echo $timer->getProgressAsciiBar(), PHP_EOL;
// 88.00%
echo $timer->getProgressPercentage(), PHP_EOL;
// 88/100
echo $timer->getProgressDone(), PHP_EOL;
-
You can also define your own output
- %b - Progress bar
- %c - Count
- %p - Percentage
%c %b %pwill print
567/1234 █████████░░░░░░░░░░░ 45.95%
统计信息
- 总下载量: 47
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-04-15