Wallogit.com
2017 © Pedro Peláez
travail/time-chronograph
\Time\Chronograph -, (*1)
use \Time\Chronograph; require_once '/path/to/vendor/autoload.php'; $chrono = new Chronograph(); $chrono->start(); $chrono->mark('before_do_something'); /* Do something */ $chrono->mark('after_do_something'); $chrono->stop(); $diff = $chrono->diff('before_do_something', 'after_do_something'); echo sprintf("Took %.3f to do something", $diff); $total = $chrono->total(); echo sprintf("Took %.3f seconds\n", $total); $total_in_micro_seconds = $chrono->total(6); echo sprintf("Took %.6f seconds\n", $total_in_micro_seconds);
To install this package into your project via composer, add the following snippet to your composer.json. Then run composer install., (*2)
"require": {
"travail/time-chronograph": "dev-master"
}
If you want to install from gihub, add the following:, (*3)
"repositories": [
{
"type": "vcs",
"url": "git@github.com:travail/php-Time-Chronograph.git"
}
]
float mark(string $mark), (*4)
Returns the result of gettimeofday., (*5)
void start(void), (*6)
void stop(void), (*7)
float total([int $digit = 3]), (*8)
Returns the time between the mark $start and $end in given decimal place, 3 (millisecond) by default., (*9)
float diff(string $start, strig $end [, int $digit = 3]), (*10)
Returns the time between the mark $start and $end in given decimal place, millisecond by default., (*11)
travail, (*12)
This library is free software. You can redistribute it and/or modify it under the same terms as PHP itself., (*13)