bonsaicode / timer
1.0.5
2019-08-19 05:20 UTC
Requires
- php: >=7.1.0
README
计时器实用类。
- 用于基准测试代码的计时器类。
要求
- PHP 7.1或更高版本
安装
要在控制台安装模块,请运行以下命令
$ composer require "bonsaicode/timer"
使用
<?php
# instantiating Timer automatically starts the timer unless you pass false to the constructor
$timer = new BonsaiCode\Timer();
# [ put code here that you want to time ]
# get the elapsed time as a string, defaults to 8 decimal places
echo 'Elapsed seconds: '.$timer->get()."\n";
# restart the timer
$timer->start();
# [ put code here that you want to time ]
# pause the timer
$timer->pause();
# [ code you don't want to time ]
# resume the timer
$timer->unpause();
# show elapsed time since the last start, exclude all paused time
echo 'Elapsed seconds: '.$timer->get()."\n";
?>