- memory_get_peak_usage: documentation ( source)
- microtime: documentation ( source)
<?php
$i = 0;
$x = [];
$start = microtime( true );
do {
$x[] = array( "firstname" => "Patrick", "lastname" => "Allaert" );
++$i;
} while ( $i < 500000 );
echo microtime( true ) - $start, "\n", memory_get_peak_usage(), "\n";