php性能测试
2021-04-06 11:27
标签:function fine end == tar while ob_start and new php性能测试 标签:function fine end == tar while ob_start and new 原文地址:https://www.cnblogs.com/ysbl/p/12495822.htmldefine("BAILOUT",16);
define("MAX_ITERATIONS",1000);
class Mandelbrot
{
function Mandelbrot()
{
$d1 = microtime(1);
for ($y = -39; $y iterate($x/40.0,$y/40.0) == 0)
echo("*");
else
echo(" ");
}
echo("\n");
}
$d2 = microtime(1);
$diff = $d2 - $d1;
printf("\nPHP Elapsed %0.3f\n", $diff);
}
function iterate($x,$y)
{
$cr = $y-0.5;
$ci = $x;
$zr = 0.0;
$zi = 0.0;
$i = 0;
while (true) {
$i++;
$temp = $zr * $zi;
$zr2 = $zr * $zr;
$zi2 = $zi * $zi;
$zr = $zr2 - $zi2 + $cr;
$zi = $temp + $temp + $ci;
if ($zi2 + $zr2 > BAILOUT)
return $i;
if ($i > MAX_ITERATIONS)
return 0;
}
}
}
ob_start();
$m = new Mandelbrot();
ob_end_flush();、
此代码测试cpu在不用php版本下的执行速度