Download the PHP package cspray/precision-stopwatch without Composer
On this page you can find all versions of the php package cspray/precision-stopwatch. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download cspray/precision-stopwatch
More information about cspray/precision-stopwatch
Files in cspray/precision-stopwatch
Package precision-stopwatch
Short Description A small library for keeping track of the duration between precise points in time.
License MIT
Informations about the package precision-stopwatch
Precision Stopwatch
Precisely time PHP scripts and code, down to the nanosecond, by utilizing the hrtime function.
Installing
Composer is the only supported method for installing this library.
Usage Guide
Using the provided functionality involves the following steps:
- Create a new instance of
Cspray\PrecisionStopwatch\Stopwatch
- Call
Stopwatch::start()
- Do the thing that you're timing!
- Call
Stopwatch::mark()
(optional, see Marking Time) - Call
Stopwatch::stop()
- Retrieve information about how long the Stopwatch ran with
Cspray\PrecisionStopwatch\Metrics
The code examples below can be executed by cloning this repo and running the scripts available in ./examples
.
Basic Usage
If you execute this example you should see output similar to the following:
Marking Time
Marking time allows you to retrieve the duration that a Stopwatch has ran to a certain point, while allowing the Stopwatch to continue running. Calling Stopwatch::mark()
will return a Cspray\PrecisionStopwatch\Marker
instance. In addition to retrieving the duration up to a certain point, available on the Marker
instance, you can retrieve the duration between markers with the Metrics
returned from Stopwatch::stop()
.
If you execute this example you should see output similar to the following: