Exemplo n.º 1
0
 /**
  * @return mixed get the data to be serialized
  */
 public function getData()
 {
     $queries = $duplicates = array();
     $queryTotals = array('count' => 0, 'time' => 0);
     if (count(DB::getConnections())) {
         $threshold = Config::get('slow_query');
         foreach (DB::getQueryLog() as $query) {
             $queryTotals['count'] += 1;
             //base informations
             $query['sql'] = str_replace("\n", '', $query['query']);
             $queryTotals['time'] += $query['time'];
             //duplicate queries
             $query['sql_simplified'] = $this->simplifiedQuery($query['sql']);
             if (array_key_exists($query['sql_simplified'], $duplicates)) {
                 $duplicates[$query['sql_simplified']]['time'] += $query['time'];
                 $duplicates[$query['sql_simplified']]['qty']++;
             } else {
                 $duplicates[$query['sql_simplified']] = array('time' => $query['time'], 'qty' => 1);
             }
             if ($query['time'] >= $threshold) {
                 $query['slow'] = 'slow';
             }
             //TODO :: slow query threshold
             //TODO :: implement "explain"
             $queries[] = $query;
         }
     }
     foreach ($duplicates as $query => $duplicate) {
         if ($duplicate['qty'] == 1) {
             unset($duplicates[$query]);
         }
     }
     return array('database' => array('queries' => $queries, 'duplicates' => $duplicates, 'popup' => array('Total Queries' => $queryTotals['count'], 'Total Time' => Utils::getReadableTime($queryTotals['time']))));
 }
Exemplo n.º 2
0
 /**
  * @return mixed get the data to be serialized
  */
 public function getData()
 {
     //this may happen in case of early termination
     if (empty($this->data)) {
         $this->register();
     }
     $this->data['events'] = Stopwatch::getEvents();
     //In some cases the start time can be calculated wrong, in this case we take the first timer's origin
     $stopwatchStartTime = current($this->data['events']);
     if ($stopwatchStartTime->getOrigin() / 1000 < $this->data['appStartTime']) {
         $this->data['appStartTime'] = $stopwatchStartTime->getOrigin() / 1000;
     }
     $this->data['totalTime'] = microtime(true) - $this->data['appStartTime'];
     $this->data['popup'] = array('Load time' => Utils::getReadableTime($this->data['totalTime'] * 1000), 'Max time' => Utils::getReadableTime(ini_get('max_execution_time') * 1000));
     return array('time' => $this->data);
 }
Exemplo n.º 3
0
 /**
  * @return mixed get the data to be serialized
  */
 public function getData()
 {
     $files = get_included_files();
     $fileList = array();
     $largestFile = 0;
     $totalSize = 0;
     foreach ($files as $file) {
         if (file_exists($file)) {
             $size = filesize($file);
         } else {
             $size = 0;
         }
         $fileList[] = array('name' => Utils::path($file), 'size' => $size);
         $totalSize += $size;
         if ($size > $largestFile) {
             $largestFile = $size;
         }
     }
     return array('files' => array('list' => $fileList, 'popup' => array("Total Files" => count($files), "Total Size" => Utils::getReadableSize($totalSize), "Largest File" => Utils::getReadableSize($largestFile))));
 }
Exemplo n.º 4
0
<h2>Files</h2>

<?php 
if (empty($files)) {
    ?>
    <h3>No loaded files.</h3>
<?php 
} else {
    ?>
    <table class="op-table">
    <?php 
    foreach ($files as $file) {
        ?>
        <tr><td><span class="indicator"><?php 
        echo \Onigoetz\Profiler\Utils::getReadableSize($file['size']);
        ?>
</span> <?php 
        echo $file['name'];
        ?>
</td></tr>
        <?php 
    }
    ?>
    </table>
<?php 
}
Exemplo n.º 5
0
    if (count($duplicates)) {
        ?>
        <table class="op-table">
            <?php 
        foreach ($duplicates as $sql => $query) {
            ?>
                <tr>
                    <td class="query <?php 
            array_key_exists('slow', $query) ? $query['slow'] : '';
            ?>
>
                    <span class=" indicator"><?php 
            echo $query['qty'];
            ?>
&times; (Total <?php 
            echo \Onigoetz\Profiler\Utils::getReadableTime($query['time']);
            ?>
)</span>
                    <pre><?php 
            echo $sql;
            ?>
</pre>
                    </td>
                </tr>
            <?php 
        }
        ?>
        </table>
    <?php 
    } else {
        ?>
Exemplo n.º 6
0
 public function onCloseHeaders(Request $request, Response $response)
 {
     try {
         $this->app['stopwatch']->stop('Framework running.');
     } catch (\LogicException $e) {
         //no problem here, this event might not be started
     }
     //Generate data anyway
     $this->collectors->generateData();
     $this->collectors->saveData();
     $time = '';
     $time_collector = $this->collectors->getData();
     if (array_key_exists('time', $time_collector)) {
         $time = Utils::getReadableTime($time_collector['time']['totalTime'] * 1000);
     }
     $response->headers->add(array('X-Profile-env' => $this->app->environment(), 'X-Profile-time' => $time));
 }
Exemplo n.º 7
0
    };
    return View::render($view_path . '/panels/variables.php', array('variables' => $data['variables'], 'e' => $e));
}, 'title' => function ($data, $icon) {
    return new PanelTitle('Variables');
}));
Panels::register(array('name' => 'database', 'datasource' => array('database'), 'icon' => "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAQAAAC1+jfqAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAEYSURBVBgZBcHPio5hGAfg6/2+R980k6wmJgsJ5U/ZOAqbSc2GnXOwUg7BESgLUeIQ1GSjLFnMwsKGGg1qxJRmPM97/1zXFAAAAEADdlfZzr26miup2svnelq7d2aYgt3rebl585wN6+K3I1/9fJe7O/uIePP2SypJkiRJ0vMhr55FLCA3zgIAOK9uQ4MS361ZOSX+OrTvkgINSjS/HIvhjxNNFGgQsbSmabohKDNoUGLohsls6BaiQIMSs2FYmnXdUsygQYmumy3Nhi6igwalDEOJEjPKP7CA2aFNK8Bkyy3fdNCg7r9/fW3jgpVJbDmy5+PB2IYp4MXFelQ7izPrhkPHB+P5/PjhD5gCgCenx+VR/dODEwD+A3T7nqbxwf1HAAAAAElFTkSuQmCC", 'panel' => function ($data) use($view_path) {
    return View::render($view_path . '/panels/database.php', $data['database']);
}, 'title' => function ($data, $icon) {
    return new PanelTitle($data['database']['popup']['Total Queries'], $icon, $data['database']['popup']);
}));
Panels::register(array('name' => 'files', 'datasource' => array('files'), 'icon' => "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAGsSURBVDjLjZNLSwJRFICtFv2AgggS2vQLDFvVpn0Pi4iItm1KItvWJqW1pYsRemyyNILARbZpm0WtrJ0kbmbUlHmr4+t0z60Z7oSSAx935txzvrlPBwA4EPKMEVwE9z+ME/qtOkbgqtVqUqPRaDWbTegE6YdQKBRkJazAjcWapoGu6xayLIMoilAoFKhEEAQIh8OWxCzuQwEmVKtVMAyDtoiqqiBJEhSLRSqoVCqAP+E47keCAvfU5sDQ8MRs/OYNtr1x2PXdwuJShLLljcFlNAW5HA9khLYp0TUhSYMLHm7PLEDS7zyw3ybRqyfg+TyBtwl2sDP1nKWFiUSazFex3tk45sXjL1Aul20CGTs+syVY37igBbwg03eMsfH9gwSsrZ+Doig2QZsdNiZmMkVrKmwc18azHKELyQrOMEHTDJp8HXu1hostG8dY8PiRngdWMEq467ZwbDxwlIR8XrQLcBvn5k9Gpmd8fn/gHlZWT20C/D4k8eTDB3yVFKjX6xSbgD1If8G970Q3QbvbPehAyxL8SibJEdaxo5dikqvS28sInCjp4Tqb4NV3fgPirZ4pD4KS4wAAAABJRU5ErkJggg==", 'panel' => function ($data) use($view_path) {
    return View::render($view_path . '/panels/files.php', array('files' => $data['files']['list']));
}, 'title' => function ($data, $icon) {
    return new PanelTitle($data['files']['popup']["Total Files"], $icon, $data['files']['popup']);
}));
Panels::register(array('name' => 'monolog', 'datasource' => array('monolog'), 'icon' => "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAD3SURBVDjLY/j//z8DJRhM5Mx/rLLo8Lv/ZBsA0kyRATBDYOzy8vJsIP5fUlLyv6Cg4H92dvb/1NTU/wkJCf8jIyP/BwcH/8fqgkUHSXcFA1UCce7+t/9n7Xn9P2LiPRWyXRDae0+ld8tL8rwQ1HVHpXPTc7jmuLi47IiIiP+BgYH/vby8/js7O/+3sbH5b2Ji8l9XV/e/mpoaaiC2rX/+v3HN0/81q54OUCCWL3v8v3Tp4//Fix+T7wKQZuu8S+THAkgzzAVGRkbZ2tra/1VUVP7Lycn9FxcX/y8kJPSfh4fnPzs7+39mZmbUQARpBGG7oisddA9EAPd/1bRtLxctAAAAAElFTkSuQmCC", 'panel' => function ($data) use($view_path) {
    return View::render($view_path . '/panels/monolog.php', array('logs' => $data['monolog']['logs'], 'logger' => $data['monolog']['logger']));
}, 'title' => function ($data, $icon) {
    return new PanelTitle(count($data['monolog']['logs']), $icon);
}));
Panels::register(array('name' => 'router', 'datasource' => array('router'), 'icon' => 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAHYSURBVDjLlVLPS1RxHJynpVu7KEn0Vt+2l6IO5qGCIsIwCPwD6hTUaSk6REoUHeoQ0qVAMrp0COpY0SUIPVRgSl7ScCUTst6zIoqg0y7lvpnPt8MWKuuu29w+hxnmx8dzzmE5+l7mxk1u/a3Dd/ejDjSsII/m3vjJ9MF0yt93ZuTkdD0CnnMO/WOnmsxsJp3yd2zfvA3mHOa+zuHTjy/zojrvHX1YqunAZE9MlpUcZAaZQBNIZUg9XdPBP5wePuEO7eyGQXg29QL3jz3y1oqwbvkhCuYEOQMp/HeJohCbICMUVwr0DvZcOnK9u7GmQNmBQLJCgORxkneqRmAs0BFmDi0bW9E72PPda/BikwWi0OEHkNR14MrewsTAZF+lAAWZEH6LUCwUkUlntrS1tiG5IYlEc6LcjYjSYuncngtdhakbM5dXlhgTNEMYLqB9q49MKgsPjTBXntVgkDNIgmI1VY2Q7QzgJ9rx++ci3ofziBYiiELQEUAyhB/D29M3Zy+uIkDIhGYvgeKvIkbHxz6Tevzq6ut+ANh9fldetMn80OzZVVdgLFjBQ0tpEz68jcB4ifx3pQeictVXIEETnBPCKMLEwBIZAPJD767V/ETGwsjzYYiC6vzEP9asLo3SGuQvAAAAAElFTkSuQmCC', 'panel' => function ($data) use($view_path) {
    return View::render($view_path . '/panels/router.php', array('routes' => $data['router']));
}, 'title' => function ($data, $icon) {
    $popup = array('Routes' => count($data['router']['routes']));
    return new PanelTitle('Routes', $icon, $popup);
}));
Panels::register(array('name' => 'time', 'datasource' => array('time'), 'icon' => 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAKrSURBVDjLpdPbT9IBAMXx/qR6qNbWUy89WS5rmVtutbZalwcNgyRLLMyuoomaZpRQCt5yNRELL0TkBSXUTBT5hZSXQPwBAvor/fZGazlb6+G8nIfP0znbgG3/kz+Knsbb+xxNV63DLxVLHzqV0vCrfMluzFmw1OW8ePEwf8+WgM1UXDnapVgLePr5Nj9DJBJGFEN8+TzKqL2RzkenV4yl5ws2BXob1WVeZxXhoB+PP0xzt0Bly0fKTePozV5GphYQPA46as+gU5/K+w2w6Ev2Ol/KpNCigM01R2uPgDcQIRSJEYys4JmNoO/y0tbnY9JlxnA9M15bfHZHCnjzVN4x7TLz6fMSJqsPgLAoMvV1niSQBGIbUP3Ki93t57XhItVXjulTQHf9hfk5/xgGyzQTgQjx7xvE4nG0j3UsiiLR1VVaLN3YpkTuNLgZGzRSq8wQUoD16flkOPSF28/cLCYkwqvrrAGXC1UYWtuRX1PR5RhgTJTI1Q4wKwzwWHk4kQI6a04nQ99mUOlczMYkFhPrBMQoN+7eQ35Nhc01SvA7OEMSFzTv8c/0UXc54xfQcj/bNzNmRmNy0zctMpeEQFSio/cdvqUICz9AiEPb+DLK2gE+2MrR5qXPpoAn6mxdr1GBwz1FiclDcAPCEkTXIboByz8guA75eg8WxxDtFZloZIdNKaDu5rnt9UVHE5POep6Zh7llmsQlLBNLSMTiEm5hGXXDJ6qb3zJiLaIiJy1Zpjy587ch1ahOKJ6XHGGiv5KeQSfFun4ulb/josZOYY0di/0tw9YCquX7KZVnFW46Ze2V4wU1ivRYe1UWI1Y1vgkDvo9PGLIoabp7kIrctJXSS8eKtjyTtuDErrK8jIYHuQf8VbK0RJUsLfEg94BfIztkLMvP3v3XN/5rfgIYvAvmgKE6GAAAAABJRU5ErkJggg==', 'panel' => function ($data) use($view_path) {
    return View::render($view_path . '/panels/time.php', array('events' => $data['time']['events']));
}, 'title' => function ($data, $icon) {
    return new PanelTitle(Utils::getReadableTime($data['time']['totalTime'] * 1000), $icon, $data['time']['popup']);
}));