2017 © Pedro Peláez
 

library profiler

A profiling library for PHP using XHProf or uprofiler and providing multiple persistance layers

image

link0/profiler

A profiling library for PHP using XHProf or uprofiler and providing multiple persistance layers

  • Tuesday, August 4, 2015
  • by link0
  • Repository
  • 3 Watchers
  • 14 Stars
  • 67 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 5 Forks
  • 5 Open issues
  • 6 Versions
  • 0 % Grown

The README.md

Link0\Profiler

Latest Stable Version Total Downloads License Scrutinizer Code Quality Code Coverage Build Status, (*1)

Link0/Profiler as a layer over XHProf profiling, and persisting profiles for later analysis., (*2)

The code is quite new, so please report any bugs if you encounter them, even though unit-tests should cover 100% of the code., (*3)

All ideas are welcome, and contributors as well., (*4)

SensioLabsInsight, (*5)

Requirements

  • PHP 5.4 is required but using the latest version of PHP is highly recommended
  • XHProf or Uprofiler is required to do actual profiling

Installation

To add Link0/Profiler as a local, per-project dependency to your project, simply require the dependency link0/profiler with composer., (*6)

composer require "link0/profiler" "~1.0"

There is also a Symfony2 bundle available, see Link0/ProfilerBundle. To install it, use the following composer package, (*7)

composer require "link0/profiler-bundle" "~1.0"

To install XHProf on your machine, (*8)

pecl install -f xhprof

or, (*9)

apt-get install php5-xhprof

or, (*10)

# If you have the josegonzalez/homebrew-php formulae tapped, install them with brew.
# Change your version accordingly
brew install php55-xhprof

Quick setup with XHGui

To get started with this profiler package and XHGui, setup XHGui to listen to your MongoDB instance., (*11)

From every project that you want to profile, and aggregate the results to the centralized server, setup the following config:, (*12)

    $connectionAddress = 'mongodb://mongodb.example.com:27017';
    $mongoClient = new \Link0\Profiler\PersistenceHandler\MongoDbHandler\MongoClient($connectionAddress);
    $persistenceHandler = new \Link0\Profiler\PersistenceHandler\MongoDbHandler($mongoClient);
    $profiler = new \Link0\Profiler\Profiler($persistenceHandler);
    $profiler->start();

More in-depth

The library is all about the Profiler, you want to instantiate that and let it do it's magic, (*13)

$profiler = new \Link0\Profiler\Profiler();
$profiler->start();
print_r($profiler->stop());

If you want to start profiling using a browser based tool like XHProf Helper, You can use this method, (*14)

$profiler = new \Link0\Profiler\Profiler();
$profiler->startOn(@$_COOKIE['_profiler']);
// or
$profiler->startOn(@$_COOKIE['XHProf_Profile']);

If you want to store the results, you can pass a PersistenceHandler object to the Profiler, (*15)

$persistenceHandler = new \Link0\Profiler\PersistenceHandler\MemoryHandler();
$profiler = new \Link0\Profiler\Profiler($persistenceHandler);

This way, the results are stored in memory, may not be that convienient, but can be nice to play around with., (*16)

There is also an implementation to store profiles on the filesystem, using the Flysystem library., (*17)

$filesystemAdapter = new \League\Flysystem\Adapter\Local('/tmp/profiler');
$filesystem = new \League\Flysystem\Filesystem($filesystemAdapter);
$persistenceHandler = new \Link0\Profiler\PersistenceHandler\FilesystemHandler($filesystem);
$profiler = new \Link0\Profiler\Profiler($persistenceHandler);

The Versions

04/08 2015

dev-master

9999999-dev

A profiling library for PHP using XHProf or uprofiler and providing multiple persistance layers

  Sources   Download

MIT

The Requires

 

The Development Requires

11/03 2015

v1.0.1

1.0.1.0

A profiling library for PHP using XHProf or uprofiler and providing multiple persistance layers

  Sources   Download

MIT

The Requires

 

The Development Requires

08/03 2015

v1.0.0

1.0.0.0

A profiling library for PHP using XHProf or uprofiler and providing multiple persistance layers

  Sources   Download

MIT

The Requires

 

The Development Requires

22/11 2014

v0.1.2

0.1.2.0

A profiling library for PHP using XHProf or uprofiler and providing multiple persistance layers

  Sources   Download

MIT

The Requires

 

The Development Requires

19/10 2014

v0.1.1

0.1.1.0

A profiling library for PHP using XHProf or uprofiler and providing multiple persistance layers

  Sources   Download

MIT

The Requires

 

The Development Requires

19/10 2014

v0.1.0

0.1.0.0

A profiling library for PHP using XHProf or uprofiler and providing multiple persistance layers

  Sources   Download

MIT

The Requires

 

The Development Requires