2017 © Pedro Peláez
 

library xhprof-profiler

A small abstraction in front of the xhprof extension, with storage support

image

csa/xhprof-profiler

A small abstraction in front of the xhprof extension, with storage support

  • Sunday, May 25, 2014
  • by csarrazi
  • Repository
  • 1 Watchers
  • 0 Stars
  • 59 Installations
  • PHP
  • 0 Dependents
  • 2 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

XhProf profiler

Latest Stable Version Latest Unstable Version SensioLabs Insight Scrutinizer Quality Score Code Coverage Build Status, (*1)

Installation

composer require csa/xhprof-profiler:dev-master

Usage

Create any type of PHP web or console application, then use the following in your code:, (*2)

<?php

require_once __DIR__ . '/vendor/autoload.php';

use XhProf\Profiler;

$profiler = new Profiler();

$profiler->start();

// Your code

// You may either use $profiler->stop() at the end of the code you wish to do something with the trace,
// or let xhprof-profiler manage it, as it registers a shutdown function automatically.
$trace = $profiler->stop();

You can easily store a trace using any storage class implementing StorageInterface:, (*3)

<?php

require_once __DIR__ . '/vendor/autoload.php';

use XhProf\Profiler;
use XhProf\Storage\MemoryStorage;

$profiler = new Profiler();
$profiler->start();
$trace = $profiler->stop();
$storage = new MemoryStorage();
$storage->store($trace);

You may also override the profiler's shutdown function:, (*4)

<?php

require_once __DIR__ . '/vendor/autoload.php';

use XhProf\Storage\FileStorage;
use XhProf\Profiler;
use XhProf\Trace;

$profiler = new Profiler();

$callback = function (Trace $trace) {
    $storage = new FileStorage();
    $storage->store($trace);

    // Do whatever you want with the trace
};

$profiler->setShutdownFunction($callback);
$profiler->start();

If you are using the file storage implementation, you may fetch a trace simply by using the fetch method. You may also fetch the list of available tokens:, (*5)

<?php

require_once __DIR__ . '/vendor/autoload.php';

use XhProf\Storage\FileStorage;

$storage = new FileStorage();
echo implode(PHP_EOL, $storage->getTokens());

Todo

  • Improve context support (for both Cli or request contexts).

License

This library is under the MIT license. For the full copyright and license information, please view the LICENSE file that was distributed with this source code., (*6)

Bitdeli Badge, (*7)

The Versions

25/05 2014

dev-master

9999999-dev

A small abstraction in front of the xhprof extension, with storage support

  Sources   Download

MIT

The Requires

 

by Charles Sarrazin

25/05 2014

v1.1.0

1.1.0.0

A small abstraction in front of the xhprof extension, with storage support

  Sources   Download

MIT

The Requires

 

by Charles Sarrazin