- memory_get_usage: documentation ( source)
- asort: documentation ( source)
- rand: documentation ( source)
<?php
$memory1 = memory_get_usage(true);
print 'before: ' . $memory1 ."\n";
$keys = array();
for ($i = 0; $i<100000; $i++) {
$keys[] = 'pref:keyname:' . rand(1000000, 19999999);
}
asort($keys);
$memory2 = memory_get_usage(true);
print 'after: ' . $memory2 ."\n";
print 'allocated: ' . ($memory2 - $memory1);