- microtime: documentation ( source)
<?php
class A
{
public $_field = "abcdefghijklmnopqrstuvwxyz";
public function __construct() {}
}
class B
{
public $_field = "abcdefghijklmnopqrstuvwxyz";
}
$start = microtime(true);
for ($i = 0; $i < 100000; $i++) $r = new A();
$time_taken = microtime(true) - $start;
echo 'With construct: ' . $time_taken . 's' . PHP_EOL;
$start = microtime(true);
for ($i = 0; $i < 100000; $i++) $r = new B();
$time_taken = microtime(true) - $start;
echo 'Without construct: ' . $time_taken . 's' . PHP_EOL;