Changeset 2686 for trunk/system/views

Show
Ignore:
Timestamp:
05/22/2008 04:13:52 AM (6 months ago)
Author:
PugFish
Message:

Added start of new Profiler library

Location:
trunk/system/views
Files:
2 added
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/system/views/kohana_profiler.php

    r2593 r2686  
    1515        font: inherit; 
    1616} 
    17 #kohana-profiler table 
    18 { 
    19         font-size: 1.0em; 
    20         color: #4D6171; 
    21         width: 100%; 
    22         border-collapse: collapse; 
    23         border-top: 1px solid #E5EFF8; 
    24         border-right: 1px solid #E5EFF8; 
    25         border-left: 1px solid #E5EFF8; 
    26         margin-bottom: 10px; 
    27 } 
    28 #kohana-profiler th 
    29 { 
    30         text-align: left; 
    31         border-bottom: 1px solid #E5EFF8; 
    32         background-color: #F9FCFE; 
    33         padding: 3px; 
    34         color: #263038; 
    35 } 
    36 #kohana-profiler td 
    37 { 
    38         background-color: #FFFFFF; 
    39         border-bottom: 1px solid #E5EFF8; 
    40         padding: 3px; 
    41 } 
    42 #kohana-profiler .kp-altrow td 
    43 { 
    44         background-color: #F7FBFF; 
    45 } 
    46 #kohana-profiler .kp-totalrow td 
    47 { 
    48         background-color: #FAFAFA; 
    49         border-top: 1px solid #D2DCE5; 
    50         font-weight: bold; 
    51 } 
    52 #kp-benchmarks th 
    53 { 
    54         background-color: #FFE0E0; 
    55 } 
    56 #kp-queries th 
    57 { 
    58         background-color: #E0FFE0; 
    59 } 
    60 #kp-postdata th 
    61 { 
    62         background-color: #E0E0FF; 
    63 } 
    64 #kp-sessiondata th 
    65 { 
    66         background-color: #CCE8FB; 
    67 } 
    68 #kp-cookiedata th 
    69 { 
    70         background-color: #FFF4D7; 
    71 } 
    72 #kohana-profiler .kp-column 
    73 { 
    74         width: 100px; 
    75         border-left: 1px solid #E5EFF8; 
    76         text-align: center; 
    77 } 
    78 #kohana-profiler .kp-data, #kohana-profiler .kp-name 
    79 { 
    80         background-color: #FAFAFB; 
    81         vertical-align: top; 
    82 } 
    83 #kohana-profiler .kp-name 
    84 { 
    85         width: 200px; 
    86         border-right: 1px solid #E5EFF8; 
    87 } 
    88 #kohana-profiler .kp-altrow .kp-data, #kohana-profiler .kp-altrow .kp-name 
    89 { 
    90         background-color: #F6F8FB; 
    91 } 
     17<?php echo $styles ?> 
    9218</style> 
    9319<div id="kohana-profiler"> 
    94  
    95 <?php if (isset($benchmarks)): ?> 
    96         <table id="kp-benchmarks"> 
    97                 <tr> 
    98                         <th><?php echo Kohana::lang('profiler.benchmarks') ?></th> 
    99                         <th class="kp-column">Time</th> 
    100                         <th class="kp-column">Memory</th> 
    101                 </tr> 
    10220<?php 
    103  
    104 // Moves the first benchmark (total execution time) to the end of the array 
    105 $benchmarks = array_slice($benchmarks, 1) + array_slice($benchmarks, 0, 1); 
    106  
    107 foreach ($benchmarks as $name => $benchmark): 
    108  
    109         $class = ($name == 'total_execution') ? ' class="kp-totalrow"' : text::alternate('', ' class="kp-altrow"'); 
    110         $name = ucwords(str_replace(array('_', '-'), ' ', $name)); 
    111  
     21foreach ($profiles as $profile) 
     22{ 
     23        echo $profile->render(); 
     24} 
    11225?> 
    113                 <tr<?php echo $class ?>> 
    114                         <td><?php echo $name ?></td> 
    115                         <td class="kp-column kp-data"><?php echo number_format($benchmark['time'], 4) ?></td> 
    116                         <td class="kp-column kp-data"><?php echo number_format($benchmark['memory'] / 1024 / 1024, 2) ?> MB</td> 
    117                 </tr> 
    118 <?php 
    119  
    120 endforeach; 
    121  
    122 ?> 
    123         </table> 
    124 <?php endif; ?> 
    125  
    126 <?php if (isset($queries)): ?> 
    127         <table id="kp-queries"> 
    128                 <tr> 
    129                         <th><?php echo Kohana::lang('profiler.queries') ?></th> 
    130                         <th class="kp-column">Time</th> 
    131                         <th class="kp-column">Rows</th> 
    132                 </tr> 
    133 <?php 
    134  
    135 if ($queries === FALSE): 
    136  
    137 ?> 
    138                 <tr><td colspan="3"><?php echo Kohana::lang('profiler.no_database') ?></td></tr> 
    139 <?php 
    140  
    141 else: 
    142  
    143         if (count($queries) == 0): 
    144  
    145 ?> 
    146                 <tr><td colspan="3"><?php echo Kohana::lang('profiler.no_queries') ?></td></tr> 
    147 <?php 
    148  
    149         else: 
    150                 text::alternate(); 
    151                 $total_time = 0; 
    152                 foreach ($queries as $query): 
    153                         $total_time += $query['time']; 
    154 ?> 
    155                 <tr<?php echo text::alternate('', ' class="kp-altrow"') ?>> 
    156                         <td><?php echo html::specialchars($query['query']) ?></td> 
    157                         <td class="kp-column kp-data"><?php echo number_format($query['time'], 4) ?></td> 
    158                         <td class="kp-column kp-data"><?php echo $query['rows'] ?></td> 
    159                 </tr> 
    160 <?php 
    161  
    162                 endforeach; 
    163 ?> 
    164                 <tr class="kp-totalrow"> 
    165                         <td>Total: <?php echo count($queries) ?></td> 
    166                         <td class="kp-column kp-data"><?php echo number_format($total_time, 4) ?></td> 
    167                         <td class="kp-column kp-data">&nbsp;</td> 
    168                 </tr> 
    169 <?php 
    170  
    171         endif; 
    172 endif; 
    173  
    174 ?> 
    175         </table> 
    176 <?php endif; ?> 
    177  
    178 <?php if (isset($post)): ?> 
    179         <table id="kp-postdata"> 
    180                 <tr> 
    181                         <th colspan="2"><?php echo Kohana::lang('profiler.post_data') ?></th> 
    182                 </tr> 
    183 <?php 
    184  
    185 if (count($_POST) == 0): 
    186  
    187 ?> 
    188                 <tr><td colspan="2"><?php echo Kohana::lang('profiler.no_post') ?></td></tr> 
    189 <?php 
    190  
    191 else: 
    192         text::alternate(); 
    193         foreach ($_POST as $name => $value): 
    194  
    195 ?> 
    196                 <tr<?php echo text::alternate('', ' class="kp-altrow"') ?>> 
    197                         <td class="kp-name"><?php echo $name ?></td> 
    198                         <td> 
    199                                 <?php echo (is_array($value)) ? '<pre>'.html::specialchars(print_r($value, TRUE)).'</pre>' : html::specialchars($value) ?> 
    200                         </td> 
    201                 </tr> 
    202 <?php 
    203  
    204         endforeach; 
    205 endif; 
    206  
    207 ?> 
    208         </table> 
    209 <?php endif; ?> 
    210  
    211 <?php if (isset($session)): ?> 
    212         <table id="kp-sessiondata"> 
    213                 <tr> 
    214                         <th colspan="2"><?php echo Kohana::lang('profiler.session_data') ?></th> 
    215                 </tr> 
    216 <?php 
    217  
    218 if ( ! isset($_SESSION)): 
    219  
    220 ?> 
    221                 <tr><td colspan="2"><?php echo Kohana::lang('profiler.no_session') ?></td></tr> 
    222 <?php 
    223  
    224 else: 
    225         text::alternate(); 
    226         foreach ($_SESSION as $name => $value): 
    227  
    228 ?> 
    229                 <tr<?php echo text::alternate('', ' class="kp-altrow"') ?>> 
    230                         <td class="kp-name"><?php echo $name ?></td> 
    231                         <td> 
    232                                 <?php echo (is_array($value) OR is_object($value)) ? '<pre>'.html::specialchars(print_r($value, TRUE)).'</pre>' : html::specialchars($value) ?> 
    233                         </td> 
    234                 </tr> 
    235 <?php 
    236  
    237         endforeach; 
    238 endif; 
    239  
    240 ?> 
    241         </table> 
    242 <?php endif; ?> 
    243  
    244 <?php if (isset($cookie)): ?> 
    245         <table id="kp-cookiedata"> 
    246                 <tr> 
    247                         <th colspan="2"><?php echo Kohana::lang('profiler.cookie_data') ?></th> 
    248                 </tr> 
    249 <?php 
    250  
    251 if (count($_COOKIE) == 0): 
    252  
    253 ?> 
    254                 <tr><td colspan="2"><?php echo Kohana::lang('profiler.no_cookie') ?></td></tr> 
    255 <?php 
    256  
    257 else: 
    258         text::alternate(); 
    259         foreach ($_COOKIE as $name => $value): 
    260  
    261 ?> 
    262                 <tr<?php echo text::alternate('', ' class="kp-altrow"') ?>> 
    263                         <td class="kp-name"><?php echo $name ?></td> 
    264                         <td> 
    265                                 <?php echo (is_array($value)) ? '<pre>'.html::specialchars(print_r($value, TRUE)).'</pre>' : html::specialchars($value) ?> 
    266                         </td> 
    267                 </tr> 
    268 <?php 
    269  
    270         endforeach; 
    271 endif; 
    272  
    273 ?> 
    274         </table> 
    275 <?php endif; ?> 
    276  
     26Profiler executed in <?php echo number_format($execution_time, 3) ?>s 
    27727</div>