本文整理汇总了PHP中bsize函数的典型用法代码示例。如果您正苦于以下问题:PHP bsize函数的具体用法?PHP bsize怎么用?PHP bsize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了bsize函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getFragments
function getFragments($mem)
{
$frags = array();
foreach ($mem['block_lists'][0] as $block) {
$frags[$block['offset']] = $block['size'];
}
ksort($frags);
$text = array();
$prev_val = 0;
$i = 0;
foreach ($frags as $key => $value) {
$i++;
$key = $key - $prev_val;
$text[] = "{name: 'Used-" . bsize($key) . "',data: [" . $key . "]}";
$text[] = "{name: 'Free-" . bsize($value) . "',data: [" . $value . "]}";
$prev_val = $key + $prev_val + $value;
}
return implode(',', array_reverse($text));
}
示例2: htmlentities
if (!isset($_GET['key']) || !isset($_GET['server'])) {
echo "No key set!";
break;
}
// I'm not doing anything to check the validity of the key string.
// probably an exploit can be written to delete all the files in key=base64_encode("\n\r delete all").
// somebody has to do a fix to this.
$theKey = htmlentities(base64_decode($_GET['key']));
$theserver = $MEMCACHE_SERVERS[(int) $_GET['server']];
list($h, $p) = explode(':', $theserver);
$r = sendMemcacheCommand($h, $p, 'get ' . $theKey);
echo <<<EOB
<div class="info"><table cellspacing=0><tbody>
\t\t\t<tr><th>Server<th>Key</th><th>Value</th><th>Delete</th></tr>
EOB;
echo "<tr><td class=td-0>", $theserver, "</td><td class=td-0>", $theKey, " <br/>flag:", $r['VALUE'][$theKey]['stat']['flag'], " <br/>Size:", bsize($r['VALUE'][$theKey]['stat']['size']), "</td><td>", chunk_split($r['VALUE'][$theKey]['value'], 40), "</td>", '<td><a href="', $PHP_SELF, '&op=5&server=', (int) $_GET['server'], '&key=', base64_encode($theKey), "\">Delete</a></td>", "</tr>";
echo <<<EOB
\t\t\t</tbody></table>
\t\t\t</div><hr/>
EOB;
break;
case 5:
// item delete
if (!isset($_GET['key']) || !isset($_GET['server'])) {
echo "No key set!";
break;
}
$theKey = htmlentities(base64_decode($_GET['key']));
$theserver = $MEMCACHE_SERVERS[(int) $_GET['server']];
list($h, $p) = explode(':', $theserver);
$r = sendMemcacheCommand($h, $p, 'delete ' . $theKey);
示例3: foreach
$ptr = 0;
foreach ($mem['block_lists'][$i] as $block) {
if ($block['offset'] != $ptr) {
++$nseg;
}
$ptr = $block['offset'] + $block['size'];
/* Only consider blocks <5M for the fragmentation % */
if ($block['size'] < 5 * 1024 * 1024) {
$fragsize += $block['size'];
}
$freetotal += $block['size'];
}
$freeseg += count($mem['block_lists'][$i]);
}
if ($freeseg > 1) {
$frag = sprintf("%.2f%% (%s out of %s in %d fragments)", $fragsize / $freetotal * 100, bsize($fragsize), bsize($freetotal), $freeseg);
} else {
$frag = "0%";
}
if (graphics_avail()) {
$size = 'width=' . (2 * GRAPH_SIZE + 150) . ' height=' . (GRAPH_SIZE + 10);
echo <<<EOB
\t\t\t<img alt="" {$size} src="{$PHP_SELF}?IMG=3&{$time}">
EOB;
}
echo <<<EOB
\t\t</br>Fragmentation: {$frag}
\t\t</td>
\t\t</tr>
EOB;
if (isset($mem['adist'])) {
示例4: block_sort
}
}
}
}
function block_sort($array1, $array2)
{
if ($array1['offset'] > $array2['offset']) {
return 1;
} else {
return -1;
}
}
$mem_size = $mem['num_seg'] * $mem['seg_size'];
$mem_avail = $mem['avail_mem'];
$mem_used = $mem_size - $mem_avail;
$seg_size = bsize($mem['seg_size']);
$req_rate = sprintf("%.2f", ($cache['num_hits'] + $cache['num_misses']) / ($time - $cache['start_time']));
$hit_rate = sprintf("%.2f", $cache['num_hits'] / ($time - $cache['start_time']));
$miss_rate = sprintf("%.2f", $cache['num_misses'] / ($time - $cache['start_time']));
$insert_rate = sprintf("%.2f", $cache['num_inserts'] / ($time - $cache['start_time']));
$req_rate_user = sprintf("%.2f", ($cache_user['num_hits'] + $cache_user['num_misses']) / ($time - $cache_user['start_time']));
$hit_rate_user = sprintf("%.2f", $cache_user['num_hits'] / ($time - $cache_user['start_time']));
$miss_rate_user = sprintf("%.2f", $cache_user['num_misses'] / ($time - $cache_user['start_time']));
$insert_rate_user = sprintf("%.2f", $cache_user['num_inserts'] / ($time - $cache_user['start_time']));
$apcversion = phpversion('apc');
$phpversion = phpversion();
$number_files = $cache['num_entries'];
$size_files = bsize($cache['mem_size']);
$number_vars = $cache_user['num_entries'];
$size_vars = bsize($cache_user['mem_size']);
示例5: htmlentities
if (!isset($_GET['key']) || !isset($_GET['server'])) {
echo "No key set!";
break;
}
// I'm not doing anything to check the validity of the key string.
// probably an exploit can be written to delete all the files in key=base64_encode("\n\r delete all").
// somebody has to do a fix to this.
$theKey = htmlentities(base64_decode($_GET['key']));
$theserver = $MEMCACHE_SERVERS[(int) $_GET['server']];
list($h, $p) = explode(':', $theserver);
$r = sendMemcacheCommand($h, $p, 'get ' . $theKey);
echo <<<EOB
<div class="info"><table cellspacing="0"><tbody>
\t\t\t<tr><th>Server<th>Key</th><th>Value</th><th>Delete</th></tr>
EOB;
echo "<tr><td class='td-0'>", $theserver, "</td><td class='td-0'>", $theKey, " <br/>flag:", $r['VALUE'][$theKey]['stat']['flag'], " <br/>Size:", bsize($r['VALUE'][$theKey]['stat']['size']), "</td><td>", chunk_split($r['VALUE'][$theKey]['value'], 40), "</td>", '<td><a href="', $INSTALLER09['baseurl'], '/staffpanel.php?tool=memcache&op=5&server=', (int) $_GET['server'], '&key=', base64_encode($theKey), "\">Delete</a></td>", "</tr>";
echo <<<EOB
\t\t\t</tbody></table>
\t\t\t</div><hr/>
EOB;
break;
case 5:
// item delete
if (!isset($_GET['key']) || !isset($_GET['server'])) {
echo "No key set!";
break;
}
$theKey = htmlentities(base64_decode($_GET['key']));
$theserver = $MEMCACHE_SERVERS[(int) $_GET['server']];
list($h, $p) = explode(':', $theserver);
$r = sendMemcacheCommand($h, $p, 'delete ' . $theKey);
示例6: controller_apc
function controller_apc(&$args, $output = "inline")
{
$user = User::Singleton();
if (!($user->isLoggedIn() && $user->HasRole("ADMIN"))) {
return;
}
$vars["args"] = $args;
if (!empty($args["flush"])) {
apc_clear_cache();
$vars["message"] = "APC cache cleared";
}
$vars["apc"]["smainfo"] = apc_sma_info();
$vars["apc"]["cacheinfo"] = apc_cache_info();
$vars["time"] = time();
$nseg = $freeseg = $fragsize = $freetotal = 0;
for ($i = 0; $i < $vars["apc"]["smainfo"]['num_seg']; $i++) {
$ptr = 0;
foreach ($vars["apc"]["smainfo"]['block_lists'][$i] as $block) {
if ($block['offset'] != $ptr) {
++$nseg;
}
$ptr = $block['offset'] + $block['size'];
/* Only consider blocks <5M for the fragmentation % */
if ($block['size'] < 5 * 1024 * 1024) {
$fragsize += $block['size'];
}
$freetotal += $block['size'];
}
$freeseg += count($vars["apc"]["smainfo"]['block_lists'][$i]);
}
if ($freeseg > 1) {
$vars["frag"] = sprintf("%.2f%% (%s out of %s in %d fragments)", $fragsize / $freetotal * 100, bsize($fragsize), bsize($freetotal), $freeseg);
} else {
$vars["frag"] = "0%";
}
if ($output == "ajax") {
$vars = array("tf_debug_tab_apc" => $this->GetTemplate("./apc.tpl", $vars));
}
return $this->GetComponentResponse("./apc.tpl", $vars);
}
示例7: bsize
</div>
</div>
<div class="span4">
<div class="well well-small">
<h4><?php
echo bsize(disk_free_space($file_info->getPath()));
?>
</h4>
<p>Cache directory free size</p>
</div>
</div>
<div class="span4">
<div class="well well-small">
<h4><?php
echo bsize(disk_total_space($file_info->getPath()));
?>
</h4>
<p>Cache directory total size</p>
</div>
</div>
</div>
</section>
<section>
<a class="anchor" id="speed"></a>
<h3>Tune Cache</h3>
示例8: fill_box
fill_box($image, $y, $x, $h, 50, $col_black, $col_red);
}
$y += $h;
}
$h = ($size - 5) * $block['size'] / $s;
if ($h > 0) {
fill_box($image, $y, $x, $h, 50, $col_black, $col_green);
}
$y += $h;
$ptr = $block['offset'] + $block['size'];
}
if ($ptr < $mem['seg_size']) {
// memory at the end
$h = ($size - 5) * ($mem['seg_size'] - $ptr) / $s;
if ($h > 0) {
fill_box($image, $y, $x, $h, 50, $col_black, $col_red, bsize($mem['seg_size'] - $ptr), $j++);
}
}
}
header("Content-type: image/png");
imagepng($image);
exit;
}
function graphics_avail()
{
return extension_loaded('gd');
}
// pretty printer for byte values
//
function bsize($s)
{
示例9: foreach
<th class="vtip" title="Seconds since the last access for the most recent item evicted from this class.<br>Use this to judge how recently active your evicted data is">Evicted time</th>
<th class="vtip" title="Age of the oldest item in the LRU.">Age</th>
<th class="vtip" title="Details and keys">Link</th>
</tr>
</thead>
<tbody>
EOB;
foreach ($entries as $slabId => $slab) {
$itemsCount = $slab['number'];
$chunkSize = $slabInfo[$server][$slabId]['chunk_size'];
$itemsSpace = round($itemsCount * $chunkSize * 100 / $memcacheStats['limit_maxbytes'], 3);
$chunks_total = $slabInfo[$server][$slabId]['total_chunks'];
$chunks_used = $slabInfo[$server][$slabId]['used_chunks'];
$percentFree = round(($chunks_total - $chunks_used) * 100 / $chunks_total, 2);
$totalBytes = $chunks_total * $chunkSize;
$usedBytes = $slabInfo[$server][$slabId]['used_chunks'] * $chunkSize;
$unusedBytes = $totalBytes - $usedBytes;
$dumpUrl = $PHP_SELF . '&op=2&server=' . array_search($server, $MEMCACHE_SERVERS) . '&dumpslab=' . $slabId;
echo "\n\t\t\t\t\t<tr class=tr-{$m}>\n\t\t\t\t\t<td class=td-0>" . $slabId . "</td>\n\t\t\t\t\t<td>" . $itemsCount . "</td>\n\t\t\t\t\t<td>" . $chunkSize . "</td>\n\t\t\t\t\t<td>" . $slabInfo[$server][$slabId]['chunks_per_page'] . "</td>\n\t\t\t\t\t<td>" . $slabInfo[$server][$slabId]['total_pages'] . "</td>\n\t\t\t\t\t<td class='vtip' title='" . bsize($totalBytes) . "'>" . $chunks_total . "</td>\n\t\t\t\t\t<td class='vtip' title='" . bsize($usedBytes) . "'>" . $chunks_used . "</td>\n\t\t\t\t\t<td class='vtip' title='" . $percentFree . " % allocated chunks in this class'>" . ($chunks_total - $chunks_used) . "</td>\n\t\t\t\t\t<td class='vtip' title='" . bsize($unusedBytes) . "'>" . $unusedBytes . "</td>\n\t\t\t\t\t<td>" . $itemsSpace . "</td>\n\t\t\t\t\t<td>" . (int) $slab['evicted'] . "</td>\n\t\t\t\t\t<td>" . (int) $slab['evicted_time'] . "</td>\n <td>" . duration($time - $slab['age']) . "</td>\n\t\t\t\t\t<td class=td-0><center><a href=\"" . $dumpUrl . "\">details</a></center></td>\n\n </tr>";
$m = 1 - $m;
}
echo <<<EOB
\t\t\t</tbody></table>
\t\t\t<hr/>
EOB;
}
break;
break;
}
echo getFooter();
示例10: htmlentities
\t\t\t</tbody></table>
\t\t\t</div><hr/>
EOB;
}
break;
break;
case 4:
//item dump
if (!isset($_GET['key']) || !isset($_GET['server'])) {
echo "No key set!";
break;
}
// I'm not doing anything to check the validity of the key string.
// probably an exploit can be written to delete all the files in key=base64_encode("\n\r delete all").
// somebody has to do a fix to this.
$theKey = htmlentities(base64_decode($_GET['key']));
$theserver = $MEMCACHE_SERVERS[(int) $_GET['server']];
list($h, $p) = explode(':', $theserver);
$r = sendMemcacheCommand($h, $p, 'get ' . $theKey);
echo <<<EOB
<div class="info"><table cellspacing=0><tbody>
\t\t\t<tr><th>Server<th>Key</th><th>Value</th></tr>
EOB;
echo "<tr><td class=td-0>", $theserver, "</td><td class=td-0>", $theKey, " <br/>flag:", $r['VALUE'][$theKey]['stat']['flag'], " <br/>Size:", bsize($r['VALUE'][$theKey]['stat']['size']), "</td><td>", chunk_split($r['VALUE'][$theKey]['value'], 40), "</td></tr>";
echo <<<EOB
\t\t\t</tbody></table>
\t\t\t</div><hr/>
EOB;
break;
}
echo getFooter();
示例11: bsize
name: 'Host Status Diagrams - Memory Usage',
data: [
['Cached Files - ' + '<?php
echo $size_files;
?>
', <?php
echo $cache['mem_size'];
?>
],
['Cached Variables - ' + '<?php
echo $size_vars;
?>
', <?php
echo $cache_user['mem_size'];
?>
],
['Free Space - ' + '<?php
echo bsize($mem_avail);
?>
', <?php
echo $mem_avail;
?>
]
]
}]
});
});
</script>
</div>
</div>
</div>
示例12: bsize
$usedmemstr = bsize($usedmem);
$freemem = @$opcache_status['memory_usage']['free_memory'] ?: 0;
$freememstr = bsize($freemem);
$totalmem = $usedmem + $freemem;
$wastedmem = @$opcache_status['memory_usage']['wasted_memory'] ?: 0;
$wastedmemstr = bsize($wastedmem);
if ($totalmem) {
$memory = array('total' => bsize($totalmem), 'used' => $usedmemstr . ($totalmem > 0 ? sprintf(" (%.1f %%)", $usedmem / $totalmem * 100) : ''), 'free' => $freememstr . ($totalmem > 0 ? sprintf(" (%.1f %%)", $freemem / $totalmem * 100) : ''), 'wasted' => $wastedmemstr . ($totalmem > 0 ? sprintf(" (%.1f %%)", $wastedmem / $totalmem * 100) : ''));
}
if (isset($opcache_status['interned_strings_usage'])) {
$usedstring = @$opcache_status['interned_strings_usage']['used_memory'] ?: 0;
$usedstringstr = bsize($usedstring);
$freestring = @$opcache_status['interned_strings_usage']['free_memory'] ?: 0;
$freestringstr = bsize($freestring);
$totalstring = $usedstring + $freestring;
$stringbuffer = array('total' => bsize($totalstring), 'used' => $usedstringstr . ($totalstring > 0 ? sprintf(" (%.1f %%)", $usedstring / $totalstring * 100) : ''), 'free' => $freestringstr . ($totalstring > 0 ? sprintf(" (%.1f %%)", $freestring / $totalstring * 100) : ''), 'strcount' => number_format(@$opcache_status['interned_strings_usage']['number_of_strings'] ?: 0, 0, '.', ' '));
}
$usedkey = @$opcache_status['opcache_statistics']['num_cached_keys'] ?: 0;
$usedkeystr = number_format($usedkey, 0, '.', ' ');
$totalkey = @$opcache_status['opcache_statistics']['max_cached_keys'] ?: 0;
$wastedkey = $usedkey - (@$opcache_status['opcache_statistics']['num_cached_scripts'] ?: 0);
if (isset($opcache_status['opcache_statistics'])) {
$keystat = array('total' => number_format($totalkey, 0, '.', ' '), 'used' => $usedkeystr . ($totalkey > 0 ? sprintf(" (%.1f %%)", $usedkey / $totalkey * 100) : ''), 'wasted' => number_format($wastedkey, 0, '.', ' ') . ($totalkey > 0 ? sprintf(" (%.1f %%)", $wastedkey / $totalkey * 100) : ''));
}
$blacklistlines = '';
if (isset($opcache_info['blacklist']) && is_array($opcache_info['blacklist'])) {
foreach ($opcache_info['blacklist'] as $value) {
eval("\$blacklistlines.=\"" . getTemplate("settings/opcacheinfo/blacklist_line") . "\";");
}
}
eval("echo \"" . getTemplate("settings/opcacheinfo/showinfo") . "\";");
示例13: htmlentities
}
// I'm not doing anything to check the validity of the key string.
// probably an exploit can be written to delete all the files in key=base64_encode("\n\r delete all").
// somebody has to do a fix to this.
$theKey = htmlentities(base64_decode($_GET['key']));
$theserver = $MEMCACHE_SERVERS[(int)$_GET['server']];
list($h,$p) = explode(':',$theserver);
$r = sendMemcacheCommand($h,$p,'get '.$theKey);
echo <<<EOB
<div class="info"><table cellspacing=0><tbody>
<tr><th>Server<th>Key</th><th>Value</th><th>Delete</th></tr>
EOB;
echo "<tr><td class=td-0>",$theserver,"</td><td class=td-0>",$theKey,
" <br/>flag:",$r['VALUE'][$theKey]['stat']['flag'],
" <br/>Size:",bsize($r['VALUE'][$theKey]['stat']['size']),
"</td><td>",chunk_split($r['VALUE'][$theKey]['value'],40),"</td>",
'<td><a href="',$PHP_SELF,'&op=5&server=',(int)$_GET['server'],'&key=',base64_encode($theKey),"\">Delete</a></td>","</tr>";
echo <<<EOB
</tbody></table>
</div><hr/>
EOB;
break;
case 5: // item delete
if (!isset($_GET['key']) || !isset($_GET['server'])){
echo "No key set!";
break;
}
$theKey = htmlentities(base64_decode($_GET['key']));
$theserver = $MEMCACHE_SERVERS[(int)$_GET['server']];
list($h,$p) = explode(':',$theserver);
示例14: indexAction
//.........这里部分代码省略.........
fill_arc($image, $x, $y, $size, $angle_from * 360, $angle_to * 360, $col_black, $col_red);
if ($angle_to - $angle_from > 0.05) {
array_push($string_placement, array($angle_from, $angle_to));
}
}
$angle_from = $angle_to;
}
$angle_to = $angle_from + $block['size'] / $s;
if ($angle_to + $fuzz > 1) {
$angle_to = 1;
}
if ($angle_to * 360 - $angle_from * 360 >= 1) {
fill_arc($image, $x, $y, $size, $angle_from * 360, $angle_to * 360, $col_black, $col_green);
if ($angle_to - $angle_from > 0.05) {
array_push($string_placement, array($angle_from, $angle_to));
}
}
$angle_from = $angle_to;
$ptr = $block['offset'] + $block['size'];
}
if ($ptr < $mem['seg_size']) {
// memory at the end
$angle_to = $angle_from + ($mem['seg_size'] - $ptr) / $s;
if ($angle_to + $fuzz > 1) {
$angle_to = 1;
}
fill_arc($image, $x, $y, $size, $angle_from * 360, $angle_to * 360, $col_black, $col_red);
if ($angle_to - $angle_from > 0.05) {
array_push($string_placement, array($angle_from, $angle_to));
}
}
}
foreach ($string_placement as $angle) {
text_arc($image, $x, $y, $size, $angle[0] * 360, $angle[1] * 360, $col_black, bsize($s * ($angle[1] - $angle[0])));
}
break;
case 2:
$s = $cache['num_hits'] + $cache['num_misses'];
$a = $cache['num_hits'];
fill_box($image, 30, $size, 50, -$a * ($size - 21) / $s, $col_black, $col_green, sprintf("%.1f%%", $cache['num_hits'] * 100 / $s));
fill_box($image, 130, $size, 50, -max(4, ($s - $a) * ($size - 21) / $s), $col_black, $col_red, sprintf("%.1f%%", $cache['num_misses'] * 100 / $s));
break;
case 3:
$s = $mem['num_seg'] * $mem['seg_size'];
$a = $mem['avail_mem'];
$x = 130;
$y = 1;
$j = 1;
// This block of code creates the bar chart. It is a lot more complex than you
// would expect because we try to visualize any memory fragmentation as well.
for ($i = 0; $i < $mem['num_seg']; $i++) {
$ptr = 0;
$free = $mem['block_lists'][$i];
foreach ($free as $block) {
if ($block['offset'] != $ptr) {
// Used block
$h = (GRAPH_SIZE - 5) * ($block['offset'] - $ptr) / $s;
if ($h > 0) {
$j++;
if ($j < 75) {
fill_box($image, $x, $y, 50, $h, $col_black, $col_red, bsize($block['offset'] - $ptr), $j);
} else {
fill_box($image, $x, $y, 50, $h, $col_black, $col_red);
}
}
$y += $h;
示例15: foreach
foreach ($keys as $k) {
if (strpos($k, "ITEM") === 0) {
$item = str_replace("ITEM ", "", $k);
$item_parts = explode(" ", $item);
$items_count++;
$o = process_item($item_parts[0]);
$output[] = $o;
show_line(str_pad($o['size'], 15, " ") . " " . $o['key']);
}
}
}
show_line('');
show_line('');
show_line('');
show_line("ITEM COUNT : {$items_count}");
show_line("TOTAL SIZE: {$total_size}, " . bsize($total_size));
//echo execute("stats cachedump 32 10");
function process_item($i)
{
$name = $i;
$content = sendMemcacheCommand("get {$i}");
if (isset($content['VALUE'])) {
$size = $content['VALUE'][$i]['stat']['size'];
global $total_size;
$total_size += $size;
} else {
$size = "?";
}
return array("size" => $size, "key" => $i);
}
function execute($q)