|
cvs: pecl /apc apc.php: msg#00239php.pecl.cvs
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> |
|---|---|---|
| Previous by Date: | cvs: pecl /sdo/DAS/Relational/Scenarios 1c-C.php 1c-CD.php 1c-CRU.php 1c-CRUD.php 1c-DCsamePK.php 1c-R.php 1c-RA.php 1c-RD.php 1c-RU.php 1c-RUnull.php 1c-RUunsetPrimitive.php 1cd-C.php 1cd-CRUD.php 1cd-RA.php 1cde-C.php 1cde-CRU.php 1cde-CRUD.php 1cde-CRUDdetach.php 1cde-R.php 1e-CRUD.php company_metadata.inc.php mc-C.php mc-R.php mc-RD.php mc-RU.php: 00239, Matthew Peters |
|---|---|
| Next by Date: | cvs: pecl /sdo README: 00239, Caroline Maynard |
| Previous by Thread: | Re: cvs: pecl /apc apc.phpi: 00239, Rasmus Lerdorf |
| Next by Thread: | cvs: pecl /apc apc.php: 00239, Rasmus Lerdorf |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |