logo       

cvs: pecl /apc apc.php: msg#00239

php.pecl.cvs

Subject: cvs: pecl /apc apc.php

iliaa Thu Jul 28 13:19:21 2005 EDT

Modified files:
/pecl/apc apc.php
Log:
A bit more accurate fragmentation % calculator, based on Rasmus' formula.


http://cvs.php.net/diff.php/pecl/apc/apc.php?r1=3.33&r2=3.34&ty=u
Index: pecl/apc/apc.php
diff -u pecl/apc/apc.php:3.33 pecl/apc/apc.php:3.34
--- pecl/apc/apc.php:3.33 Thu Jul 28 12:18:06 2005
+++ pecl/apc/apc.php Thu Jul 28 13:19:20 2005
@@ -22,7 +22,7 @@

*/

-$VERSION='$Id: apc.php,v 3.33 2005/07/28 16:18:06 beckerr Exp $';
+$VERSION='$Id: apc.php,v 3.34 2005/07/28 17:19:20 iliaa Exp $';



@@ -786,17 +786,24 @@
<td class=td-0 colspan=2><br/>
EOB;

- // Fragementation:
- // Is this the correct way to calculate fragmentstation? I'm not sure...
- $biggest=0;
- for($i=0; $i<$mem['num_seg']; $i++) {
+ // Fragementation: (freeseg - 1) / total_seg
+ $nseg = $freeseg = 0;
+ for($i=0; $i<$mem['num_seg']; $i++) {
+ $ptr = 0;
foreach($mem['block_lists'][$i] as $block) {
- if ($block['size'] > $biggest)
- $biggest=$block['size'];
+ if ($block['offset'] != $ptr) {
+ ++$nseg;
+ }
+ $ptr = $block['offset'] + $block['size'];
}
+ $freeseg += count($mem['block_lists'][$i]);
+ }
+
+ if ($freeseg > 1) {
+ $frag = sprintf("%.2f%%", (($freeseg - 1) / ($freeseg + $nseg))
* 100);
+ } else {
+ $frag = "0%";
}
-
$frag=sprintf("%.2f%%",100-100*($biggest/max(0.00001,$mem['avail_mem'])));
-

if (graphics_avail()) {
$size='width='.(2*GRAPH_SIZE+50).' height='.(GRAPH_SIZE+10);
@@ -805,7 +812,7 @@
EOB;
}
echo <<<EOB
- </br>Fragmentation: : $frag
+ </br>Fragmentation: $frag
</td>
</tr>
</tbody></table>



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise