2017 © Pedro PelĂĄez
 

library illuminator

Simple chrono

image

pyrsmk/illuminator

Simple chrono

  • Thursday, January 11, 2018
  • by pyrsmk
  • Repository
  • 1 Watchers
  • 0 Stars
  • 0 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Illuminator

A collection of simple chronometers., (*1)

Install

composer require pyrsmk/illuminator

Illuminator\Chrono

Here's the base chrono., (*2)

$chrono = new Illuminator\Chrono();
// Start!
$chrono->start();
// Stop the chrono for some time...
$chrono->stop();
// Resume the chrono
$chrono->start();
// Return the time in seconds
$chrono->read();
// Reset the still running chrono
$chrono->reset();
// Return the reseted time
$chrono->read();
// Completely stop and reset the chrono
$chrono->stop();
$chrono->reset();

The time is returned as a microtime float number, in seconds. You can also read it in milliseconds with:, (*3)

$chrono->readAsMilliseconds();

Illuminator\LazyChrono

A lazy chrono that you don't need to start or whatever., (*4)

$chrono = new Illuminator\LazyChrono();
usleep(1000);
$chrono->read();

Illuminator\TimedTask

With that class, you can time a specific task., (*5)

$timedTask = new TimedTask(function () {
    usleep(1000);
});
$timedTask->read();

Note that the callback will be run each time read() is called., (*6)

License

Released under the MIT license., (*7)

The Versions

11/01 2018

dev-master

9999999-dev

Simple chrono

  Sources   Download

MIT

The Requires

  • php >=7.2.0

 

time timer stopwatch chronometer chrono