Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@plumbum
Created November 1, 2014 18:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save plumbum/90b9901daa4831432bc3 to your computer and use it in GitHub Desktop.
Save plumbum/90b9901daa4831432bc3 to your computer and use it in GitHub Desktop.
<?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