jakovic/timer 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

jakovic/timer

Composer 安装命令:

composer require jakovic/timer

包简介

A simple PHP package for measuring execution time

README 文档

README

A simple PHP package for measuring execution time in your applications.

🚀 Installation

You can install the package via Composer:

composer require jakovic/timer

🔧 Usage

First, import and create an instance of the Timer class:

use Jakovic\Timer;

✅ Basic Example

use Jakovic\Timer;

$timer = new Timer();
$timer->start();
sleep(5); // Simulate some process
$timer->end();

echo $timer->getSeconds(); // e.g. 5.0032
echo $timer->getMinutes(); // e.g. 0.0833
echo $timer->getHours();   // e.g. 0.0014
echo $timer->total();      // e.g. 00:00:05

✅ Multiple Timers Example

$timer1 = new Timer();
$timer2 = new Timer();

$timer1->start();
sleep(3);
$timer1->end();

$timer2->start();
sleep(5);
$timer2->end();

echo "Timer 1: " . $timer1->total() . "\n"; // 00:00:03
echo "Timer 2: " . $timer2->total() . "\n"; // 00:00:05

🛠 Methods

  • $timer->start() - Starts the timer
  • $timer->end() - Stops the timer
  • $timer->getSeconds() - Returns elapsed time in seconds (float), e.g., 5.0032
  • $timer->getMinutes() - Returns elapsed time in minutes (float), e.g., 0.0833
  • $timer->getHours() - Returns elapsed time in hours (float), e.g., 0.0014
  • $timer->total() - Returns elapsed time in H:i:s format, e.g., 00:00:05

📜 License

This package is open-sourced software licensed under the MIT License.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-03-17