- microtime: documentation ( source)
<?php
class PHPBench
{
protected static $start_time = 0;
protected static $end_time = 0;
public static function start()
{
return self::$start_time = microtime(true);
}
public static function end()
{
return self::$end_time = microtime(true);
}
public function __destruct()
{
print "Script executed in: " . (float)$time = self::$start_time - self::$end_time;
}
}
// Loop
$Bench = new PHPBench();
$Bench::start();
for($x = 0; $x <= 1000000; $x++)
{
print $x . '<br/>';
}
$Bench::end();
?>