/**
  * Tests the text::bytes() function.
  * @dataProvider bytes_provider
  * @group core.helpers.text.bytes
  * @test
  */
 public function bytes($bytes, $force_unit, $format, $si, $expected_result)
 {
     $result = text::bytes($bytes, $force_unit, $format, $si);
     $this->assertEquals($expected_result, $result);
 }
示例#2
0
文件: image_info.php 项目: anqqa/Anqh
			<?php 
if ($image->author_id) {
    ?>
				<dd><?php 
    echo __('Copyright &copy; :year :author', array(':year' => date('Y', strtotime($image->created)), ':author' => html::user($image->author)));
    ?>
</dd>
			<?php 
}
?>
				<dd><?php 
echo __('Added: :date', array(':date' => '<var>' . date::format('DMYYYY_HM', $image->created) . '</var>'));
?>
</dd>
				<dd><?php 
echo __('Image size: :size kB', array(':size' => '<var>' . text::bytes($image->original_size, 'KiB', '%01.2f') . '</var>'));
?>
</dd>
				<dd><?php 
echo __('Resolution: :resolution', array(':resolution' => sprintf('<var>%d×%d</var>', $image->original_width, $image->original_height)));
?>
</dd>

			<dt><?php 
echo __('Statistics');
?>
</dt>
				<dd><?php 
echo __('Comments: :comments', array(':comments' => '<var>' . $image->comments . '</var>'));
?>
</dd>
示例#3
0
</td>
						<td><?php 
        echo $lines;
        ?>
</td>
					</tr>
					<?php 
        $total_size += $size;
        $total_lines += $lines;
        ?>
				<?php 
    }
    ?>
				<tr align="left">
					<th colspan="2">total</th>
					<th><?php 
    echo text::bytes($total_size);
    ?>
</th>
					<th><?php 
    echo number_format($total_lines);
    ?>
</th>
				</tr>
			</table>
		</div>
	<?php 
}
?>

</div>
示例#4
0
 /**
  * Add toolbar data to FirePHP console
  *
  */
 private static function firephp()
 {
     $firephp = FirePHP::getInstance(TRUE);
     $firephp->fb('KOHANA DEBUG TOOLBAR:');
     // Globals
     $globals = array('Post' => empty($_POST) ? array() : $_POST, 'Get' => empty($_GET) ? array() : $_GET, 'Cookie' => empty($_COOKIE) ? array() : $_COOKIE, 'Session' => empty($_SESSION) ? array() : $_SESSION);
     foreach ($globals as $name => $global) {
         $table = array();
         $table[] = array($name, 'Value');
         foreach ((array) $global as $key => $value) {
             if (is_object($value)) {
                 $value = get_class($value) . ' [object]';
             }
             $table[] = array($key, $value);
         }
         $message = "{$name}: " . count($global) . ' variables';
         $firephp->fb(array($message, $table), FirePHP::TABLE);
     }
     // Database
     $query_stats = self::get_queries();
     //$total_time = $total_rows = 0;
     $table = array();
     $table[] = array('DB profile', 'SQL Statement', 'Time', 'Memory');
     foreach ((array) $query_stats['data'] as $db => $queries) {
         unset($queries['total']);
         foreach ($queries as $query) {
             $table[] = array($db, str_replace("\n", ' ', $query['name']), number_format($query['time'] * 1000, 3), number_format($query['memory'] / 1024, 3));
         }
     }
     $message = 'Queries: ' . $query_stats['count'] . ' SQL queries took ' . number_format($query_stats['time'], 3) . ' seconds and ' . $query_stats['memory'] . ' b';
     $firephp->fb(array($message, $table), FirePHP::TABLE);
     // Benchmarks
     $groups = self::get_benchmarks();
     // application benchmarks
     $total = array_pop($groups);
     $table = array();
     $table[] = array('Group', 'Benchmark', 'Count', 'Time', 'Memory');
     foreach ((array) $groups as $group => $benchmarks) {
         foreach ((array) $benchmarks as $name => $benchmark) {
             $table[] = array(ucfirst($group), ucwords($benchmark['name']), number_format($benchmark['total_time'], 3) . ' s', text::bytes($benchmark['total_memory']));
         }
     }
     $message = 'Application tooks ' . number_format($total['total_time'], 3) . ' seconds and ' . text::bytes($total['total_memory']) . ' memory';
     $firephp->fb(array($message, $table), FirePHP::TABLE);
 }
 /**
  * Add toolbar data to FirePHP console
  */
 private static function firephp()
 {
     $firephp = FirePHP::getInstance(TRUE);
     $firephp->fb('KOHANA DEBUG TOOLBAR:');
     // Globals
     $globals = array('Post' => empty($_POST) ? array() : $_POST, 'Get' => empty($_GET) ? array() : $_GET, 'Cookie' => empty($_COOKIE) ? array() : $_COOKIE, 'Session' => empty($_SESSION) ? array() : $_SESSION);
     foreach ($globals as $name => $global) {
         $table = array();
         $table[] = array($name, 'Value');
         foreach ((array) $global as $key => $value) {
             if (is_object($value)) {
                 $value = get_class($value) . ' [object]';
             }
             $table[] = array($key, $value);
         }
         $message = "{$name}: " . count($global) . ' variables';
         $firephp->fb(array($message, $table), FirePHP::TABLE);
     }
     // Database
     $queries = self::get_queries();
     $total_time = $total_rows = 0;
     $table = array();
     $table[] = array('SQL Statement', 'Time', 'Rows');
     foreach ((array) $queries as $query) {
         $table[] = array(str_replace("\n", ' ', $query['query']), number_format($query['time'], 3), $query['rows']);
         $total_time += $query['time'];
         $total_rows += $query['rows'];
     }
     $message = 'Queries: ' . count($queries) . ' SQL queries took ' . number_format($total_time, 3) . ' seconds and returned ' . $total_rows . ' rows';
     $firephp->fb(array($message, $table), FirePHP::TABLE);
     // Benchmarks
     $benchmarks = self::get_benchmarks();
     $table = array();
     $table[] = array('Benchmark', 'Time', 'Memory');
     foreach ((array) $benchmarks as $name => $benchmark) {
         $table[] = array(ucwords(str_replace(array('_', '-'), ' ', str_replace(SYSTEM_BENCHMARK . '_', '', $name))), number_format($benchmark['time'], 3) . ' s', text::bytes($benchmark['memory']));
     }
     $message = 'Benchmarks: ' . count($benchmarks) . ' benchmarks took ' . number_format($benchmark['time'], 3) . ' seconds and used up ' . text::bytes($benchmark['memory']) . ' memory';
     $firephp->fb(array($message, $table), FirePHP::TABLE);
 }
示例#6
0
        foreach ((array) $benchmarks as $benchmark) {
            ?>
						<tr class="<?php 
            echo text::alternate('odd', 'even');
            ?>
">
							<td align="left"><?php 
            echo $benchmark['name'];
            ?>
</td>
							<td align="right"><?php 
            echo sprintf('%.2f', $benchmark['time'] * 1000);
            ?>
 ms</td>
							<td align="right"><?php 
            echo text::bytes($benchmark['memory']);
            ?>
</td>
						</tr>
					<?php 
        }
        ?>
				<?php 
    } else {
        ?>
					<tr class="<?php 
        echo text::alternate('odd', 'even');
        ?>
">
						<td colspan="3">no benchmarks to display</td>
					</tr>