speedy / timer
A simple timer for measuring the speed of a script.
Installs: 2 127
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: >=7.1.0
Requires (Dev)
- phpunit/phpunit: ^6.0.0
- symfony/var-dumper: ^3.1
This package is not auto-updated.
Last update: 2024-11-07 08:11:51 UTC
README
Speedy Timer
Speedy Timer is a package component for script runtime measurement that may be used for debugging applications within system development.
Requirements
- >= php 7.1
Installation
$ composer require speedy/timer
Usage
Basic usage for activating the measurement of the runtime script:
require_once __DIR__ . '/vendor/autoload.php'; use Speedy\Timer\Timer; $timer = new Timer(); $timer->start(); // some code $item = $timer->stop(); var_dump($item->getTime()); // show run-time in milliseconds var_dump($item->getTime(true)); // show run-time in microseconds
You can use shortcut to create the Timer class instance:
require_once __DIR__ . '/vendor/autoload.php'; $timer = timer()->start(); //some code $item = $timer->stop(); var_dump($item->getTime());
To track the duration of different parts of the script it is possible to name each item in the following way:
require_once __DIR__ . '/vendor/autoload.php'; $timer = timer()->start('test1'); //some code $timer = timer()->start('test2'); //some code $item = $timer->stop('test1); var_dump($item->getTime()); //some code $item2 = $timer->stop('test2); var_dump($item2->getTime())