Skip to content

zeroem/profile-dux

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Profile - Doesn't Use Xdebug

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

About

PHP Profiling tool to use in the absence of XDebug

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages