- microtime: documentation ( source)
- str_repeat: documentation ( source)
- memory_get_usage: documentation ( source)
- sprintf: documentation ( source)
<?php
$time = microtime(true);
$memo = memory_get_usage(true);
// BEGIN
$x = str_repeat('0', 1024*1024);
$y = $x;
// END
$memo = memory_get_usage(true) - $memo;
$time = microtime(true) - $time;
echo sprintf("%dms - %.2fmo", $time*1000, $memo/1024/1024);