标签:
<?php
set_time_limit(0);
echo ‘memory_limit:‘. $memory = ini_get(‘memory_limit‘).‘‘;
$string = str_repeat(‘abcde‘,50000); // 运行字符串, 可修改这儿.
$memory =($memory+0)*1024*1024;
$runtime = memory_get_usage();
$runcount = abs(($memory / strlen($string)) * 0.99); // 为什么+1? 因为需要留点内存给其它变量或者计算式.
$i = 0;
while($i < $runcount){
$i ++;
$data .= $string;
}
echo ‘all run count: ‘.$i.‘‘;
echo ‘\$data string size:‘. sprintf(‘%01.2f‘,strlen($data) / 1024 / 1024) .‘MB ‘;
echo ‘run memory: ‘. sprintf(‘%01.2f‘,(memory_get_usage() - $runtime) / 1024 / 1024) .‘MB‘;
echo ‘memory_get_peak_usage: ‘.sprintf(‘%01.2f‘,(memory_get_peak_usage() - $runtime) / 1024 / 1024) .‘MB<br>‘;
exit();
标签:
原文地址:http://www.cnblogs.com/u0mo5/p/4790391.html