Exemplo n.º 1
0
require __DIR__ . '/bootstrap/libraries.php';
/**
 * Library defaults. You can override any of these settings by passing
 * in an array when adding the library via `Libraries::add`
 *
 * @see \lithium\core\Libraries::add()
 */
$options = Libraries::get('li3_profiler') + array('jquery' => '//cdnjs.cloudflare.com/ajax/libs/jquery/1.7.1/jquery.min.js', 'prettify' => '/li3_profiler', 'environment' => 'development', 'inject' => true, 'filters' => array('action\\Dispatcher', 'action\\Controller', 'security\\Auth', 'net\\http\\Media', 'storage\\Session', 'data\\Model'));
// Set our options and enable our `Profiler` by default.
$options['bootstrap'] = false;
Libraries::add('li3_profiler', $options);
\Profiler::enable();
// Set our jQuery options.
if ($options['jquery']) {
    \ProfilerRenderer::setIncludeJquery(true);
    \ProfilerRenderer::setJqueryLocation($options['jquery']);
} else {
    \ProfilerRenderer::setIncludeJquery(false);
}
// Set our prettify options.
if ($options['prettify']) {
    \ProfilerRenderer::setIncludePrettify(true);
    \ProfilerRenderer::setPrettifyLocation($options['prettify']);
} else {
    \ProfilerRenderer::setIncludePrettify(false);
}
/**
 * Due to the way the `Environment` class determines the current configuration
 * we need to wait for the `Dispatcher` to start up before we know where we are.
 */
Filters::apply('lithium\\action\\Dispatcher', '_callable', function ($self, $params, $chain) {
Exemplo n.º 2
0
<?php

date_default_timezone_set("UTC");
require "../profiler.php";
Profiler::enable();
ProfilerRenderer::setIncludeJquery(true);
ProfilerRenderer::setJqueryLocation('https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js');
ProfilerRenderer::setPrettifyLocation("../code-prettify");
$s1 = Profiler::start('Step 1');
//do some important things!
usleep(500000);
// 0.5 sec
$s1->end();
$s2 = Profiler::start('Step 2');
//more important things
usleep(100000);
// 0.1 sec
$s3 = Profiler::start('Step 3');
//some nested things..that are important and stuff.
sleep(1);
$sql = Profiler::sqlStart("SELECT * FROM TABLE WHERE 1");
usleep(1500000);
// 1.5 sec
$sql->end();
$s3->end();
$s2->end();
?>
<!DOCTYPE html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>php-profiler demo</title>