Example #1
0
 /**
  * Transform point to human readable form
  *
  * @param	array	$point
  * @return	array
  */
 public static function humanize($point, $measure = NULL)
 {
     if (is_array($point) && !isset($point['time'])) {
         $result = array();
         foreach ($point as $key => $dot) {
             $result[$key] = self::humanize($dot, $measure);
         }
         return $result;
     }
     return array('time' => self::microToSec($point['time']), 'memory' => File::fromBytes($point['memory'], $measure));
 }
Example #2
0
 /**
  * Render
  */
 public function render()
 {
     $this->prepareOptions();
     if (NULL == $this->options->value) {
         if ($this->options->allowed_types) {
             $this->notice(t('Следующие типы файлов разрешены к загрузке: <b>%s</b>.', $this->options->allowed_types->toString('</b>, <b>')));
         }
         if ($this->options->maxsize) {
             $this->notice(t('Максимальный размер файла <b>%s</b>.', File::fromBytes(File::toBytes($this->options->maxsize), NULL, 2)));
         }
         if ($this->notices->count()) {
             $this->options->description .= '<ul class="file-notice"><li>' . $this->notices->toString('</li><li>') . '</li></ul>';
         }
     }
     $tpl = new Template($this->template);
     $tpl->assign($this->options);
     $this->code = $tpl->render();
     $this->decorate();
     return $this->code;
 }
Example #3
0
<?php

$points = bench();
// Специально задаем нулевой элемент, потому что счёт ведется от единицы
$db_bench = array();
$total_time = 0;
$memory = 0;
foreach ($points as $key => $point) {
    if (0 === strpos($key, 'db.query')) {
        $memory += $point['memory'];
        $point = humanize_bench($point);
        $db_bench[] = $point;
        $total_time += $point['time'];
    }
}
echo t('<b>База данных:</b> %d <i class="icon icon-time"></i> %.3f<i class="icon icon-leaf"></i>%s', sizeof($queries), $total_time, File::fromBytes($memory));
?>
 <?php 
if ($queries) {
    ?>
<a id="db-trace-queries-handler" class="btn btn-mini"><i class="icon icon-eye-open"></i></a>
<div id="db-trace-queries" class="well" style="display:none;">
    <?php 
    foreach ($queries as $key => $query) {
        ?>
        <?php 
        echo icon('time') . ' ' . round($db_bench[$key]['time'], 4) . ' ' . icon('leaf') . ' ' . $db_bench[$key]['memory'];
        ?>
        <?php 
        echo '<code class="prettyprint lang-sql">' . $query . '</code>';
        ?>
Example #4
0
 /**
  * Check file size
  * @param string $size
  * @param string $maxsize
  * @return
  */
 public function checkMaxSize($size, $maxsize)
 {
     $maxsize = File::toBytes($maxsize);
     if ($size > $maxsize) {
         $this->error(t('Максимально разрешенный размер загружаемого файла составляет <b>%s</b>. Вы же пытаетесь загрузкить файл размером <b>%s</b>.', File::fromBytes($maxsize, 'auto', 2), File::fromBytes($size, 'auto', 2)));
         return FALSE;
     }
     return TRUE;
 }