zeroem/profile-dux

There is no license information available for the latest version (dev-master) of this package.

A profiling utility to use in the absence of XDebug

dev-master 2012-04-22 00:42 UTC

This package is not auto-updated.

Last update: 2024-05-11 10:55:49 UTC


README

A simple object oriented profiling tool

Usage

Normal Usage

$profiler = new \Dux\Profiler();

for($i=0; $i < $n; $i++) {
    $profiler->start();
    // do something that you want proifled
    $profiler->end();
}

\Dux\Aggregate\Report::generate(
    $profiler, 
    new \Dux\Aggregate\Mean()
)->renderAggregate();

// Outputs:
// Mean execution time: (mean)ms

Special Circumstances

When profiling sub-millisecond execution times, the overhead of the method calls can greatly impact your profiling results. To combat this, simply generate the microtime values and add them to the profiler after execution.

NOTE: Only use microtime(), not microtime(true). Floating point numbers lose precision as they get larger. To deal with this, profile-dux makes use of the string representation of microtime which separates the millisecond offset from the Unix timestamp.

$profiler = new \Dux\Profiler();

for($i=0; $i < $n; $i++) {
    $start = microtime();
    // do something that you want proifled
    $end = microtime();
    $profiler->addProfile($start,$end);
}

Installation

Simply add zeroem/profile-dux to your Composer requirements:

"require": {
    "zeroem/profile-dux":"*"
}

and install your dependencies:

$> php composer.phar install