Beispiel #1
0
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>
</head>
<body>
	
<?php 
Profiler::render();
Beispiel #2
0
// Define used classes.
use lithium\util\collection\Filters;
use lithium\data\Connections;
// Attach to the `Connections` adapters after dispatch.
Filters::apply('\\lithium\\action\\Dispatcher', '_callable', function ($self, $params, $chain) {
    /**
     * Loop over all defined `Connections` adapters and tack in our
     * filter on the `_execute` method.
     */
    foreach (Connections::get() as $connection) {
        $connection = Connections::get($connection);
        $connection->applyFilter('_execute', function ($self, $params, $chain) {
            $profiler = \Profiler::sqlStart($params['sql']);
            $response = $chain->next($self, $params, $chain);
            $profiler->end();
            return $response;
        });
        $connection->applyFilter('read', function ($self, $params, $chain) {
            $response = $chain->next($self, $params, $chain);
            \Profiler::start($response->model());
            $info = $response->result()->resource();
            $profiler = \Profiler::sqlStart(json_encode($info->info()));
            $profiler->end();
            \Profiler::end($response->model());
            return $response;
        });
    }
    // Return the controller.
    return $chain->next($self, $params, $chain);
});
 public static function sqlStart($query)
 {
     return Profiler::sqlStart($query);
 }