PHP Classes

PHP Profiler: Measure the elapsed time between PHP code sections

Recommend this page to a friend!
  Info   View files View files (12)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2023-10-06 (15 days ago) RSS 2.0 feedNot yet rated by the usersTotal: 28 This week: 1All time: 10,933 This week: 119Up
Version License PHP version Categories
profiler-php 1.0MIT/X Consortium ...7Time and Date, Performance and optimi..., P...
Description 

Author

This package can measure the elapsed time between PHP code sections.

It provides a class with function calls that note the current time in microseconds and associate with the named label of each checkpoint.

The class also provides functions that return arrays with the times of each checkpoint and also the times that passed between checkpoints.

Picture of Smoren  Freelight
  Performance   Level  
Name: Smoren Freelight <contact>
Classes: 31 packages by
Country: Russian Federation Russian Federation
Innovation award
Innovation award
Nominee: 14x

Details

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
)
*/

  Files folder image Files  
File Role Description
Files folder image.github (1 directory)
Files folder imagesrc (2 files)
Files folder imagetests (3 files, 2 directories)
Accessible without login Plain text file codeception.yml Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  .github  
File Role Description
Files folder imageworkflows (1 file)

  Files folder image Files  /  .github  /  workflows  
File Role Description
  Accessible without login Plain text file test_master.yml Data Auxiliary data

  Files folder image Files  /  src  
File Role Description
  Plain text file Profiler.php Class Class source
  Plain text file ProfilerException.php Class Class source

  Files folder image Files  /  tests  
File Role Description
Files folder imageunit (1 file)
Files folder image_support (1 file)
  Accessible without login Plain text file coding_standard.xml Data Auxiliary data
  Accessible without login Plain text file unit.suite.yml Data Auxiliary data
  Accessible without login Plain text file _bootstrap.php Aux. Auxiliary script

  Files folder image Files  /  tests  /  unit  
File Role Description
  Plain text file ProfilerTest.php Class Class source

  Files folder image Files  /  tests  /  _support  
File Role Description
  Plain text file UnitTester.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:28
This week:1
All time:10,933
This week:119Up