enricospa/microtime-tracker

A PHP micro library for time tracking

v0.1.1 2021-02-02 09:02 UTC

This package is auto-updated.

Last update: 2024-04-29 04:58:36 UTC


README

A PHP micro library for time tracking.

About

Have you ever find yourself using PHP microtime function for timing script execution?

Microtime Tracker is microtime, with superpowers 💪

Getting Started

To use this library in your project simply require it with Composer.

Installation

Install using Composer

composer require enricospa/microtime-tracker

Usage

Code example:

use Enricospa\MicrotimeTracker\Tracker;
use Enricospa\MicrotimeTracker\TimestampHolder;

// Init the tracker
$tracker = new Tracker(new TimestampHolder);

// First snap starts the tracker
$tracker->snap('Start tracking');

// Sleep for a while
usleep(2000000);

$tracker->snap('Slept for a while');

echo "<pre>";
echo $tracker->reportConsole();
echo "</pre>";

More examples coming...

License

See the LICENSE file for license rights and limitations (MIT).