Simone: Speicherverbrauch zur Laufzeit berechnen

Beitrag lesen

Danke nochmal an Alle!!

Hier der Code

	  
	print_d(free_m());  
  
  
  
  
  
function print_d($array_debug, $exit = false)  
{  
    echo "<pre>";  
    echo "-------------------------------------------<br>";  
    echo " Count  =  <b>" . count($array_debug) . "</b><br>";  
    echo "-------------------------------------------<br><br>";  
    print_r($array_debug);  
    echo "</pre>";  
    if ($exit == true) {  
        exit();  
    }  
}  
  
  
  
  
  
    function free_m()  
    {  
        $cmd = 'free -m | grep "buffers/cache" | sed -e "s/-\/+ buffers\/cache:\s*\([0-9]*\)\s*\([0-9]*\).*/\\1 \/ \\2/"';  
        $memoryUsage = explode('/', exec($cmd));  
        if (is_array($memoryUsage)) {  
            if (count($memoryUsage)) {  
                $memory = array(  
                    'used' => trim($memoryUsage[0]),  
                    'free' => trim($memoryUsage[1]),  
                );  
                $memory['total'] = $memory['used'] + $memory['free'];  
                if ($memory['total']) {  
                    $memory['%'] = $memory['used'] / $memory['total'] * 100;  
                }  
            return $memory;  
			}  
        }  
    }  

model name	: Intel(R) Xeon(R) CPU E5645 @ 2.40GHz  
-------------------------------------------  
-------------------------------------------  
 Count  =  4  
-------------------------------------------  
  
Array  
(  
    [used] => 771  
    [free] => 7217  
    [total] => 7988  
    [%] => 9.65197796695  
)  
  
model name	: Intel(R) Xeon(R) CPU X3440 @ 2.53GHz  
-------------------------------------------  
-------------------------------------------  
 Count  =  4  
-------------------------------------------  
  
Array  
(  
    [used] => 253  
    [free] => 1751  
    [total] => 2004  
    [%] => 12.624750499  
)  
  
  
model name	: AMD Athlon(tm) II X3 405e Processor  
-------------------------------------------  
-------------------------------------------  
 Count  =  4  
-------------------------------------------  
  
Array  
(  
    [used] => 889  
    [free] => 3038  
    [total] => 3927  
    [%] => 22.6381461676  
)