Exemplo n.º 1
0
 /**
  * Ends the current session, gathering all the available environment data
  *
  * @param string                    $response   HTML response for the current request
  * @param EurekaProfiler_DB_Adapter $db_adapter DB Adapter used to query the database
  * @param boolean                   $store      Store current profile data in the database
  */
 public function finish($response = '', $store = false)
 {
     $this->disable();
     //Create events tree
     $event_tree = array();
     foreach ($this->_session->events as $event) {
         $closest = null;
         //Search event that starts before and ends after current
         foreach ($this->_session->events as $sibling) {
             if ($sibling != $event && $sibling->duration > 0 && $sibling->timemark < $event->timemark && $sibling->timemark + $sibling->duration > $event->timemark + $event->duration) {
                 $closest = $sibling;
             }
         }
         if ($closest) {
             $closest->add_child($event);
         } else {
             $event_tree[] = $event;
         }
     }
     $this->_session->events = $event_tree;
     $this->_session->gather_data($response, $this->db_adapter);
     //Store session data
     if ($store) {
         if (!$this->db_adapter) {
             throw new RuntimeException('A DB adapter must be configured before storing profiler sessions');
         }
         $this->db_adapter->insert($this->_table, array('date' => $this->_session->start, 'url' => EurekaProfiler_Tools::current_url(), 'data' => base64_encode(gzencode(serialize($this->_session), 9))));
     }
 }
Exemplo n.º 2
0
function render_included(EurekaProfiler_Session $session, $tab)
{
    ?>
    <table class="summary">
        <tr>
            <td style="background: <?php 
    echo $tab['color'];
    ?>
;">
                <h3><?php 
    echo EurekaProfiler_Tools::readable_number(count($session->loaded_files));
    ?>
</h3>
                <h4>Total files</h4>
            </td>
        </tr>
        <tr>
            <td style="background: <?php 
    echo $tab['alternate'];
    ?>
;">
                <h3><?php 
    echo EurekaProfiler_Tools::readable_size($session->total_included_size());
    ?>
</h3>
                <h4>Total size</h4>
            </td>
        </tr>
        <tr>
            <td class="border" style="background: <?php 
    echo $tab['color'];
    ?>
;padding-top:0">
                <?php 
    $chart_rows = array();
    foreach ($session->loaded_files as $file) {
        $chart_rows[] = array($file->path, $file->size);
    }
    echo render_chart($chart_rows, 'File');
    ?>
                <h4>Size chart</h4>
            </td>
        </tr>
    </table>
    <div class="data-wrapper">
        <table class="data">
            <?php 
    $show = array();
    foreach ($session->loaded_files as $file) {
        $show[$file->path] = EurekaProfiler_Tools::readable_size($file->size);
    }
    basic_row('', $show);
    ?>
        </table>
    </div>
<?php 
}