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