定制 giraffesummer/stopwatch 二次开发

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

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

giraffesummer/stopwatch

最新稳定版本:1.0.7

Composer 安装命令:

composer require giraffesummer/stopwatch

包简介

README 文档

README

Install: composer require giraffesummer/stopwatch

Time your functions, commands and tasks stopwatch style using this package.

It's build with Laravel (9) in mind, but it might work without it.

It's super easy to get started, there's only 3 functions:

Getting started

You can start using the stopwatch by creating a new instance of it.

import GiraffeSummer\Stopwatch\Stopwatch

use GiraffeSummer\Stopwatch\Stopwatch;

$sw = new Stopwatch();

Functions

The functions Start and Lap will return a formatted time string.

Start

Start will return the starting time of the stopwatch.
This should always be: 00:00:00.000
usage:

$sw->start(); //00:00:00.000

Lap

Lap is equivalent to the lap button on a stopwatch,
this will show the current elapsed time of the stopwatch,
since it was started or reset.
usage:

$sw->lap(); //00:00:05.9547

Reset

Reset will reset the time back to 0.
usage:

$sw->reset();

Example

here's an example of it all together.

$sw = new Stopwatch();
echo $sw->start();
$sleep = rand(1, 5);
echo "sleep: " . $sleep;
sleep($sleep);
echo $sw->lap();

This will sleep for a random number of seconds between 1 and 5, and lap before and after to see how long it was.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Unknown
  • 更新时间: 2022-10-14