/
test4.php
40 lines (25 loc) · 1.17 KB
/
test4.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
function test4($input) {
echo "function1-begin:" . (xdebug_memory_usage() - $GLOBALS['startMemory']) . " bytes \n<br />";
foreach ($input as $key => $value) {
$input[$key] = null;
}
echo "function1-end:" . (xdebug_memory_usage() - $GLOBALS['startMemory']) . " bytes \n<br />";
return $input;
}
function test4_ref(&$input) {
echo "function2-begin:" . (xdebug_memory_usage() - $GLOBALS['startMemory']) . " bytes \n<br />";
foreach ($input as $key => $value) {
$input[$key] = null;
}
echo "function2-end:" . (xdebug_memory_usage() - $GLOBALS['startMemory']) . " bytes \n<br />";
}
$GLOBALS['startMemory'] = xdebug_memory_usage();
echo "start:" . (xdebug_memory_usage() - $GLOBALS['startMemory']) . " bytes \n<br />";
$array = range(1, 100000);
echo "array:" . (xdebug_memory_usage() - $GLOBALS['startMemory']) . " bytes \n<br />";
$array = test4($array);
echo "array-test4:" . (xdebug_memory_usage() - $GLOBALS['startMemory']) . " bytes \n<br />";
test4_ref($array);
echo "array-test4_ref:" . (xdebug_memory_usage() - $GLOBALS['startMemory']) . " bytes \n<br />";
echo "end:" . (xdebug_memory_usage() - $GLOBALS['startMemory']) . " bytes \n<br />";