PHP Classes

File: README.md

Recommend this page to a friend!
  Classes of Smoren Freelight   PHP Profiler   README.md   Download  
File: README.md
Role: Documentation
Content type: text/markdown
Description: Documentation
Class: PHP Profiler
Measure the elapsed time between PHP code sections
Author: By
Last change:
Date: 8 months ago
Size: 1,421 bytes
 

Contents

Class file image Download

profiler

Packagist PHP Version Support Scrutinizer Code Quality Coverage Status Build and test License: MIT

Profiler helper

How to install to your project

composer require smoren/profiler

Unit testing

composer install
composer test-init
composer test

Usage

use Smoren\Profiler\Profiler;

function someTask()
{
    Profiler::start('first');
    usleep(10000);
    Profiler::stop('first');

    Profiler::start('second');
    usleep(20000);
    Profiler::stop('second');
}

for($i=0; $i<10; ++$i) {
    someTask();
}

Profiler::profile('third', function() {
    usleep(30000);
});

print_r(Profiler::getStatTime());
/*
Array
(
    [second] => 0.2015209197998
    [third] => 0.20024418830872
    [first] => 0.10135746002197
)
*/

print_r(Profiler::getStatCalls());
/*
Array
(
    [first] => 10
    [second] => 10
    [third] => 1
)
*/