定制 district5/timer 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

district5/timer

最新稳定版本:1.0.0

Composer 安装命令:

composer require district5/timer

包简介

District5 Timer Library

README 文档

README

About

This library supports timer functionality.

Installing

This library requires no other libraries.

composer require district5/timer

Running Unit Tests:

$ composer install --dev
$ ./vendor/bin/phpunit

Usage

Stopwatch

The stopwatch class can be instantiated and used to measure time at intervals from stopwatch start:

$stopwatch = new \District5\Timer\Stopwatch();
$stopwatch->start();

...

$secondsPassed = $stopwatch->secondsPassed();

You can also set a max time so a boolean check can be made to see if that time has passed. This is useful when working with cron tasks where there is a maximum execution time.

$maxTimeSeconds = 300;

$stopwatch = new \District5\Timer\Stopwatch($maxTimeSeconds);
$stopwatch->start();

while (!$stopwatch->hasMaxTimePassed())
{
    // do some work
}

In the above example you should take into account how long an item could take to process an iteration in the while loop to set the max seconds allowed less than the max time a cron can run - time to process 1 loop iteration.

Issues

Log a bug report!

统计信息

  • 总下载量: 108
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: mit
  • 更新时间: 2022-10-19