提升PHP性能之改变Zend引擎分发方式
ot;, 3877);
define("IC", 29573); $LAST = 42; for ($i=1; $i<=$N; $i++) { $ary[$i] = gen_random(1); } heapsort_r($N, $ary); printf("%.10f\n", $ary[$N]); } /****/ function mkmatrix ($rows, $cols) { $count = 1; $mx = array(); for ($i=0; $i<$rows; $i++) { for ($j=0; $j<$cols; $j++) { $mx[$i][$j] = $count++; } } return($mx); } function mmult ($rows, $cols, $m1, $m2) { $m3 = array(); for ($i=0; $i<$rows; $i++) { for ($j=0; $j<$cols; $j++) { $x = 0; for ($k=0; $k<$cols; $k++) { $x += $m1[$i][$k] * $m2[$k][$j]; } $m3[$i][$j] = $x; } } return($m3); } function matrix($n) { $SIZE = 30; $m1 = mkmatrix($SIZE, $SIZE); $m2 = mkmatrix($SIZE, $SIZE); while ($n--) { $mm = mmult($SIZE, $SIZE, $m1, $m2); } print "{$mm[0][0]} {$mm[2][3]} {$mm[3][2]} {$mm[4][4]}\n"; } /****/ function nestedloop($n) { $x = 0; for ($a=0; $a<$n; $a++) for ($b=0; $b<$n; $b++) for ($c=0; $c<$n; $c++) for ($d=0; $d<$n; $d++) for ($e=0; $e<$n; $e++) for ($f=0; $f<$n; $f++) $x++; print "$x\n"; } /****/ function sieve($n) { $count = 0; while ($n-- > 0) { $count = 0; $flags = range (0,8192); for ($i=2; $i<8193; $i++) { if ($flags[$i] > 0) { for ($k=$i+$i; $k <= 8192; $k+=$i) { $flags[$k] = 0; } $count++; } } } print "Count: $count\n"; } /****/ function strcat($n) { $str = ""; while ($n-- > 0) { $str .= "hello\n"; } $len = strlen($str); print "$len\n"; } /*****/ function getmicrotime() { $t = gettimeofday(); return ($t['sec'] + $t['usec'] / 1000000); } function start_test() { ob_start(); return getmicrotime(); } function end_test($start, $name) { global $total; $end = getmicrotime(); ob_end_clean(); $total += $end-$start; $num = number_format($end-$start,3); $pad = str_repeat(" ", 24-strlen($name)-strlen($num)); echo $name.$pad.$num."\n"; ob_start(); return getmicrotime(); } function total() { global $total; $pad = str_repeat("-", 24); echo $pad."\n"; $num = number_format($total,3); $pad = str_repeat(" ", 24-strlen("Total")-strlen($num)); echo "Total".$pad.$num."\n"; } $t0 = $t = start_test(); simple(); $t = end_test($t, "simple"); simplecall(); $t = end_test($t, "simplecall&q |
凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢! |