<i>Smarty plugin test</i><br><br>
{cache file="cache.smarty_example.tmp" time="20"}
<b>Hello Smarty!</b><br>
In cached part it's {$date}<br>
<i>This part will expire in 20 s</i><br>
Output is stored in <b>./cache.test_01.tmp</b><br><br>
{php}
function microtime_float()
{
list($usec, $sec) = explode(" ", microtime());
return ((float)$usec + (float)$sec);
}
function bcpi($precision=30){
$accuracy = ($precision+5)*45/32;
//accuracy worked till the 180th $precision, almost used 30 second to calculate
bcscale($precision+5);
$n = 1;
$bcatan1 = 0;
$bcatan2 = 0;
while($n < $accuracy){
//atan functions
$bcatan1 = bcadd($bcatan1, bcmul(bcdiv(pow(-1, $n+1), $n * 2 - 1), bcpow(0.2, $n * 2 -1)));
$bcatan2 = bcadd($bcatan2, bcmul(bcdiv(pow(-1, $n+1), $n * 2 - 1), bcpow(bcdiv(1,239), $n * 2 -1)));
++$n;
}
return bcmul(4,bcsub(bcmul(4, $bcatan1),$bcatan2),5);
}
$time = microtime_float();
$pi = bcpi(40);
echo("<b>pi = ".$pi."</b><br><br>");
echo("<b>This part is executed every 10 seconds</b><br>");
echo("<b>Time of execution: <u>".(microtime_float() - $time)." s</u></b><br><br>");
{/php}
{/cache}
<b>This part is executed every time</b><br>
Real time is {$date}<br>
|