Skip to content

dpoltoratsky/simple-php-profiler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

Simple PHP Profiler

This is the tool to profile any code you have.

This initial version contains only time profiling for now.

Example

This simple example demonstrates basic usage of profiler.

<?php
    require_once 'Profiler.php';

    class ToProfile {
    
        protected $profiler;


        public function __construct() {
            $this->profiler = new Profiler( './toProfile' );                
        }


        public function methodToProfile() {
            $profilingSession = $this->profiler->start( 'methodToProfile' );

            sleep(1);

            $profilingSession->step( 'Before some long playing code...' );

            sleep(3);

            $profilingSession->step( 'After some long playing code...' );

            sleep(1);

            $profilingSession->stop();

        }
    }

    $toProfile = new ToProfile();
    
    $toProfile->methodToProfile();

?>

This code will generate ./toProfile/methodToProfile.log file with following content:

1355658919 (2012.12.16 15:03:19) 923325723 1 Execution started 1355658919.1375 sec
1355658920 (2012.12.16 15:03:20) 923325723 2 Before some long code... 1.0012290477753 sec
1355658923 (2012.12.16 15:03:23) 923325723 3 After some long code... 3.0012099742889 sec
1355658924 (2012.12.16 15:03:24) 923325723 4 Execution is complete. Total time is  5.0037221908569 sec    

About

Simple PHP profiler

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages