jakovic / timer
A simple PHP package for measuring execution time
Installs: 1 729
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/jakovic/timer
Requires
- php: >=8.0
This package is auto-updated.
Last update: 2025-12-18 09:14:32 UTC
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 inH:i:sformat, e.g.,00:00:05
📜 License
This package is open-sourced software licensed under the MIT License.