时间:2021-07-01 10:21:17 帮助过:3人阅读
m = 0;$t 占用: 360
$m = memory_get_usage();
$t = array('id' => 1, 'name' => 'none');
echo '$t 占用: ', memory_get_usage() - $m, PHP_EOL;
$data = array();
echo '空的 $data 占用: ', memory_get_usage() - $m, PHP_EOL;
$m = memory_get_usage();
for($i=0; $i<1000; $i++) {
$data[] = null;
}
echo '1000 个空元素的 $data 占用: ', memory_get_usage() - $m, PHP_EOL;
$data = array();
$m = memory_get_usage();
for($i=0; $i<1000; $i++) {
$data[] = $t;
}
echo '1000 个$t元素的 $data 占用: ', memory_get_usage() - $m, PHP_EOL;
$data = array();
$m = memory_get_usage();
for($i=0; $i<1000; $i++) {
$data[] = array('id' => 1, 'name' => 'none');
}
echo '1000 个实体元素的 $data 占用: ', memory_get_usage() - $m, PHP_EOL;