Giter Club home page Giter Club logo

phpsimpleprofiler's Introduction

PhpSimpleProfiler

Lightweight php profiler library

##Install You may install the PhpSimpleProfiler with Composer (recommended) or manually.

##Usage This example assumes you are autoloading dependencies using Composer or any other PSR-0 compliant autoloader.

PhpSimpleProfiler available method:

  • setOption($name , $value) Set the option (if $name is a valid option name) value with the desidered one. Available option : 'active' (bool) (default = true) If setted to false no profile will recorded 'handler' (PhpSimpleProfiler\Handler\IHandler) (default = PhpSimpleProfiler\HandlerStreamHandler) The object that manipulate and return the data 'realUsage' (bool) (default = false) Set it to TRUE to get the real size of memory allocated from system (all the memory used by the engine php), set it to FALSE to get only the memory used by emalloc() (only script)

  • add($message) Add an entry to the statistical profile.

  • stop() Ends the profiler.

  • printData() Gets the data.

###Handlers

  • StreamHandler This handler is intended to print profile data in a log file

  • HTMLHandler This handler is intended to show data into a web page

###Example

// Create a new PhpSimpleProfiler
$psp = new PhpSimpleProfiler\PhpSimpleProfiler(array('realUsage' =>true));

// Add profiled entry
$psp->add('Before loop');

$y = 0;
for($i = 0; $i<1000; ++$i){
	$y++;	
}

// Add profiled entry
$psp->add('After loop');

// Stop the profiler
$psp->stop();

// Print the result
echo $psp->printData();

// You shold see something like this:
/*
Time: 1380207924 | Memory Usage: 0.75 MB | execution_time: 1.4066696166992E-5 | Info: Initial state
Time: 1380207924 | Memory Usage: 0.75 MB | execution_time: 0.00024199485778809 | Info: Before loop
Time: 1380207924 | Memory Usage: 0.75 MB | execution_time: 0.00027799606323242 | Info: After loop
Time: 1380207924 | Memory Usage: 0.75 MB | execution_time: 1.6927719116211E-5 | Info: Final state

Peak of memory usage: 0.75 MB

CPU elaboration time: 0.00055694580078125
*/

##License The PhpSimpleProfiler is released under the MIT public license

phpsimpleprofiler's People

Contributors

sigjlr avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.