Stopwatch in PHP
class StopWatch
{
private static $fTimeStart = 0.00;
private static $fTotal = 0.00;
public static function start()
{
self::$fTimeStart = microtime(true);
self::$fTotal = 0.00;
}
public static function stop()
{
$fTimeEnd = (microtime(true)-self::$fTimeStart);
echo "Zeit: ".number_format($fTimeEnd, 15)."s\n";
}
}
StopWatch::start();
for($i = 0; $i < 1000000; $i++)
{
//mache irgendetwas...
}
StopWatch::stop();
/*
* Ausgabe:
* Zeit: 0.051145076751709s
*/
Url: http://sklueh.de/2012/10/ausfuhrungszeit-innerhalb-eines-php-skripts-messen/
Language: PHP | User: sklueh | Created: Sep 24, 2013 | Tags: php stopwatch