Created
November 1, 2014 18:41
-
-
Save plumbum/90b9901daa4831432bc3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
define('USE_LINK', true); | |
$start_time = microtime(true); | |
$array = array(); | |
for($i =0; $i < 100000; $i++) { | |
$array[] = array( | |
'mem' => memory_get_usage(), | |
); | |
} | |
$gen_time = microtime(true); | |
if(USE_LINK) { | |
foreach($array as $k => &$item) { | |
$item['time'] = microtime(true); | |
} | |
unset($item); | |
} else { | |
foreach($array as $k => $item) { | |
$array[$k]['time'] = microtime(true); | |
} | |
} | |
$computed_time = microtime(true); | |
$mem1 = memory_get_peak_usage(); | |
echo 'mems '.round($mem1/1024/1024, 2)."Mb\r\n"; | |
echo "Gen time: ".($gen_time-$start_time)."\r\n"; | |
echo "Computed time: ".($computed_time-$gen_time)."\r\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment