weew/timer
最新稳定版本:v1.0.1
Composer 安装命令:
composer require weew/timer
包简介
Simple timer.
README 文档
README
Table of contents
Installation
composer require weew/timer
Introduction
This very simple library can be used to benchmark execution times of your code, or simply whenever you need a stopwatch.
Basic usage
You can retrieve duration between the timer start and stop.
$timer = new Timer(); $timer->start(); sleep(1); $timer->stop(); echo $timer->getDuration(); // 1.0234
Checkpoints
You can create custom checkpoints whenever and retrieve the elapsed time until the checkpoint was reached.
$timer = new Timer(); $timer->start(); $timer->createCheckpoint('foo'); $timer->stop(); $timer->getStartTime(); // returns start time in microseconds $timer->getStopTime(); // returns stop time $timer->getCheckpoint('start'); // returns start time $timer->getCheckpoint('stop'); // returns stop time $timer->getCheckpoint('foo'); // returns time of the checkpoint foo
Duration between checkpoints
You can measure duration between the checkpoints.
$timer = new Timer(); $timer->createCheckpoint('foo'); sleep(1); $timer->createCheckpoint('bar'); // returns time elapsed since checkpoint foo till now $timer->getDuration('foo'); // returns duration between checkpoints foo and bar $timer->getDuration('foo', 'bar'); $timer->stop(); // returns time between checkpoints foo and stop $timer->getDuration('foo');
统计信息
- 总下载量: 8.76k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 1
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-07-16