@ 2014-07-14T23:06:06Z <?php
//date_default_timezone_set('UTC');
set_time_limit(120);
ini_set('max_execution_time', 120);
echo "PHP VERSION: ".PHP_VERSION."\n";
function simple() {
$a = 0;
for ($i = 0; $i < 1000000; $i++)
$a++;
$thisisanotherlongname = 0;
for ($thisisalongname = 0; $thisisalongname < 1000000; $thisisalongname++)
$thisisanotherlongname++;
}
/****/
function simplecall() {
for ($i = 0; $i < 1000000; $i++)
strlen("hallo");
}
/****/
function hallo($a) {
}
function simpleucall() {
for ($i = 0; $i < 1000000; $i++)
hallo("hallo");
}
/****/
function simpleudcall() {
for ($i = 0; $i < 1000000; $i++)
hallo2("hallo");
}
function hallo2($a) {
}
/****/
function mandel() {
$w1=50;
$h1=150;
$recen=-.45;
$imcen=0.0;
$r=0.7;
$s=0; $rec=0; $imc=0; $re=0; $im=0; $re2=0; $im2=0;
$x=0; $y=0; $w2=0; $h2=0; $color=0;
$s=2*$r/$w1;
$w2=40;
$h2=12;
for ($y=0 ; $y<=$w1; $y=$y+1) {
$imc=$s*($y-$h2)+$imcen;
for ($x=0 ; $x<=$h1; $x=$x+1) {
$rec=$s*($x-$w2)+$recen;
$re=$rec;
$im=$imc;
$color=1000;
$re2=$re*$re;
$im2=$im*$im;
while( ((($re2+$im2)<1000000) && $color>0)) {
$im=$re*$im*2+$imc;
$re=$re2-$im2+$rec;
$re2=$re*$re;
$im2=$im*$im;
$color=$color-1;
}
if ( $color==0 ) {
print "_";
} else {
print "#";
}
}
print "<br>";
flush();
}
}
/****/
function mandel2() {
$b = " .:,;!/>)|&IH%*#";
//float r, i, z, Z, t, c, C;
for ($y=30; printf("\n"), $C = $y*0.1 - 1.5, $y--;){
for ($x=0; $c = $x*0.04 - 2, $z=0, $Z=0, $x++ < 75;){
for ($r=$c, $i=$C, $k=0; $t = $z*$z - $Z*$Z + $r, $Z = 2*$z*$Z + $i, $z=$t, $k<5000; $k++)
if ($z*$z + $Z*$Z > 500000) break;
echo $b[$k%16];
}
}
}
/****/
function Ack($m, $n){
if($m == 0) return $n+1;
if($n == 0) return Ack($m-1, 1);
return Ack($m - 1, Ack($m, ($n - 1)));
}
function ackermann($n) {
$r = Ack(3,$n);
print "Ack(3,$n): $r\n";
}
/****/
function ary($n) {
for ($i=0; $i<$n; $i++) {
$X[$i] = $i;
}
for ($i=$n-1; $i>=0; $i--) {
$Y[$i] = $X[$i];
}
$last = $n-1;
print "$Y[$last]\n";
}
/****/
function ary2($n) {
for ($i=0; $i<$n;) {
$X[$i] = $i; ++$i;
$X[$i] = $i; ++$i;
$X[$i] = $i; ++$i;
$X[$i] = $i; ++$i;
$X[$i] = $i; ++$i;
$X[$i] = $i; ++$i;
$X[$i] = $i; ++$i;
$X[$i] = $i; ++$i;
$X[$i] = $i; ++$i;
$X[$i] = $i; ++$i;
}
for ($i=$n-1; $i>=0;) {
$Y[$i] = $X[$i]; --$i;
$Y[$i] = $X[$i]; --$i;
$Y[$i] = $X[$i]; --$i;
$Y[$i] = $X[$i]; --$i;
$Y[$i] = $X[$i]; --$i;
$Y[$i] = $X[$i]; --$i;
$Y[$i] = $X[$i]; --$i;
$Y[$i] = $X[$i]; --$i;
$Y[$i] = $X[$i]; --$i;
$Y[$i] = $X[$i]; --$i;
}
$last = $n-1;
print "$Y[$last]\n";
}
/****/
function ary3($n) {
for ($i=0; $i<$n; $i++) {
$X[$i] = $i + 1;
$Y[$i] = 0;
}
for ($k=0; $k<1000; $k++) {
for ($i=$n-1; $i>=0; $i--) {
$Y[$i] += $X[$i];
}
}
$last = $n-1;
print "$Y[0] $Y[$last]\n";
}
/****/
function fibo_r($n){
return(($n < 2) ? 1 : fibo_r($n - 2) + fibo_r($n - 1));
}
function fibo($n) {
$r = fibo_r($n);
print "$r\n";
}
/****/
function hash1($n) {
for ($i = 1; $i <= $n; $i++) {
$X[dechex($i)] = $i;
}
$c = 0;
for ($i = $n; $i > 0; $i--) {
if ($X[dechex($i)]) { $c++; }
}
print "$c\n";
}
/****/
function hash2($n) {
for ($i = 0; $i < $n; $i++) {
$hash1["foo_$i"] = $i;
$hash2["foo_$i"] = 0;
}
for ($i = $n; $i > 0; $i--) {
foreach($hash1 as $key => $value) $hash2[$key] += $value;
}
$first = "foo_0";
$last = "foo_".($n-1);
print "$hash1[$first] $hash1[$last] $hash2[$first] $hash2[$last]\n";
}
/****/
function gen_random ($n) {
global $LAST;
return( ($n * ($LAST = ($LAST * IA + IC) % IM)) / IM );
}
function heapsort_r($n, &$ra) {
$l = ($n >> 1) + 1;
$ir = $n;
while (1) {
if ($l > 1) {
$rra = $ra[--$l];
} else {
$rra = $ra[$ir];
$ra[$ir] = $ra[1];
if (--$ir == 1) {
$ra[1] = $rra;
return;
}
}
$i = $l;
$j = $l << 1;
while ($j <= $ir) {
if (($j < $ir) && ($ra[$j] < $ra[$j+1])) {
$j++;
}
if ($rra < $ra[$j]) {
$ra[$i] = $ra[$j];
$j += ($i = $j);
} else {
$j = $ir + 1;
}
}
$ra[$i] = $rra;
}
}
function heapsort($N) {
global $LAST;
define("IM", 139968);
define("IA", 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";
// flush();
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");
simpleucall();
$t = end_test($t, "simpleucall");
simpleudcall();
$t = end_test($t, "simpleudcall");
mandel();
$t = end_test($t, "mandel");
mandel2();
$t = end_test($t, "mandel2");
ackermann(7);
$t = end_test($t, "ackermann(7)");
ary(50000);
$t = end_test($t, "ary(50000)");
ary2(50000);
$t = end_test($t, "ary2(50000)");
ary3(2000);
$t = end_test($t, "ary3(2000)");
fibo(30);
$t = end_test($t, "fibo(30)");
hash1(50000);
$t = end_test($t, "hash1(50000)");
hash2(500);
$t = end_test($t, "hash2(500)");
heapsort(20000);
$t = end_test($t, "heapsort(20000)");
matrix(20);
$t = end_test($t, "matrix(20)");
nestedloop(12);
$t = end_test($t, "nestedloop(12)");
sieve(30);
$t = end_test($t, "sieve(30)");
strcat(200000);
$t = end_test($t, "strcat(200000)");
total($t0, "Total");
echo 'Memory (MB): '.( (function_exists('memory_get_usage')) ? number_format(memory_get_usage()/1024/1024, 2) : '-' );
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).
Version System time (s) User time (s) Memory (MiB) 7.3.0 0.148 0.709 22.07 7.2.13 0.126 0.776 22.00 7.2.12 0.085 0.749 21.76 7.2.11 0.121 0.774 22.06 7.2.10 0.169 0.852 21.76 7.2.9 0.147 0.797 22.03 7.2.8 0.160 0.786 21.82 7.2.7 0.169 0.794 22.09 7.2.6 0.239 0.786 22.08 7.2.5 0.251 0.905 21.91 7.2.4 0.151 0.778 22.01 7.2.3 0.167 0.892 21.94 7.2.2 0.156 0.803 22.06 7.2.1 0.204 0.800 21.96 7.2.0 0.085 0.673 23.11 7.1.25 0.176 1.180 20.98 7.1.24 0.128 1.164 21.01 7.1.23 0.147 1.176 20.83 7.1.22 0.176 1.137 21.00 7.1.21 0.161 1.187 20.78 7.1.20 0.174 1.131 20.69 7.1.19 0.264 1.199 20.58 7.1.18 0.227 1.195 20.70 7.1.17 0.187 1.198 20.60 7.1.16 0.151 1.210 20.88 7.1.15 0.176 1.174 20.83 7.1.14 0.144 1.161 20.86 7.1.13 0.196 1.192 20.83 7.1.12 0.153 1.238 20.80 7.1.11 0.218 1.269 20.91 7.1.10 0.162 1.184 20.65 7.1.9 0.181 1.148 20.90 7.1.8 0.214 1.137 20.85 7.1.7 0.129 0.948 21.75 7.1.6 0.123 0.998 21.68 7.1.5 0.111 0.969 21.34 7.1.4 0.128 1.140 20.84 7.1.3 0.128 1.192 20.73 7.1.2 0.209 1.174 20.88 7.1.1 0.000 1.740 21.66 7.1.0 0.007 1.699 21.72 7.0.33 0.143 1.199 20.62 7.0.32 0.174 1.199 20.56 7.0.31 0.181 1.179 20.62 7.0.30 0.178 1.182 20.62 7.0.29 0.203 1.206 20.33 7.0.28 0.178 1.214 20.61 7.0.27 0.153 1.177 20.46 7.0.26 0.301 1.198 20.45 7.0.25 0.210 1.234 20.36 7.0.24 0.116 1.229 20.72 7.0.23 0.244 1.194 20.74 7.0.22 0.223 1.229 20.52 7.0.21 0.157 1.201 20.44 7.0.20 0.105 1.047 21.33 7.0.19 0.236 1.264 20.59 7.0.18 0.126 1.276 20.49 7.0.17 0.189 1.235 20.58 7.0.16 0.183 1.222 20.63 7.0.15 0.010 1.759 21.59 7.0.14 0.000 1.793 21.48 7.0.13 0.003 1.708 21.71 7.0.12 0.003 1.754 21.75 7.0.11 0.003 1.700 21.44 7.0.10 0.007 1.724 21.28 7.0.9 0.007 1.744 21.65 7.0.8 0.013 1.741 21.67 7.0.7 0.003 1.808 21.46 7.0.6 0.003 1.881 21.49 7.0.5 0.003 1.770 21.64 7.0.4 0.007 1.700 17.46 7.0.3 0.003 1.655 17.60 7.0.2 0.007 1.729 17.46 7.0.1 0.003 1.729 17.66 7.0.0 0.007 1.712 17.63 5.6.38 0.033 2.251 26.54 5.6.37 0.028 2.180 26.30 5.6.36 0.024 2.200 26.17 5.6.35 0.035 2.263 26.29 5.6.34 0.025 2.246 26.46 5.6.33 0.017 2.191 26.28 5.6.32 0.033 2.163 26.67 5.6.31 0.033 2.233 26.58 5.6.30 0.017 2.479 26.26 5.6.29 0.010 2.482 26.43 5.6.28 0.010 2.488 26.77 5.6.27 0.023 2.414 26.61 5.6.26 0.013 2.482 26.39 5.6.25 0.007 2.490 26.42 5.6.24 0.013 2.448 26.52 5.6.23 0.010 2.454 26.66 5.6.22 0.013 2.475 26.57 5.6.21 0.007 2.469 26.35 5.6.20 0.007 2.475 26.25 5.6.19 0.017 2.479 26.44 5.6.18 0.020 2.465 26.50 5.6.17 0.020 2.476 26.50 5.6.16 0.003 2.485 26.32 5.6.15 0.020 2.443 26.42 5.6.14 0.010 2.477 26.25 5.6.13 0.013 2.483 26.63 5.6.12 0.017 2.459 26.60 5.6.11 0.023 2.408 26.63 5.6.10 0.010 2.473 26.37 5.6.9 0.007 2.488 26.50 5.6.8 0.013 2.483 26.69 5.6.7 0.020 2.455 26.71 5.6.6 0.010 2.487 26.40 5.6.5 0.010 2.461 26.71 5.6.4 0.026 2.466 26.66 5.6.3 0.053 2.436 26.72 5.6.2 0.053 2.419 26.17 5.6.1 0.040 2.376 26.20 5.6.0 0.043 2.435 26.37 5.5.38 0.013 2.481 23.29 5.5.37 0.010 2.488 23.34 5.5.36 0.020 2.470 23.41 5.5.35 0.007 2.488 23.41 5.5.34 0.013 2.481 23.29 5.5.33 0.007 2.482 23.27 5.5.32 0.013 2.475 23.12 5.5.31 0.010 2.487 23.29 5.5.30 0.017 2.447 23.05 5.5.29 0.010 2.474 23.31 5.5.28 0.017 2.457 23.27 5.5.27 0.020 2.476 23.13 5.5.26 0.007 2.491 22.91 5.5.25 0.010 2.486 23.18 5.5.24 0.020 2.436 23.35 5.5.23 0.010 2.485 23.26 5.5.22 0.023 2.472 23.28 5.5.21 0.023 2.471 23.24 5.5.20 0.027 2.452 23.27 5.5.19 0.020 2.477 23.20 5.5.18 0.007 2.448 23.01 5.5.17 0.036 2.404 23.10 5.5.16 0.017 2.438 23.40 5.5.15 0.043 2.291 23.36 5.5.14 0.043 2.272 22.84 5.5.13 0.040 2.424 23.16 5.5.12 0.037 2.321 23.32 5.5.11 0.063 2.339 23.26 5.5.10 0.053 2.407 23.13 5.5.9 0.030 2.336 23.34 5.5.8 0.040 2.383 22.78 5.5.7 0.043 2.277 23.39 5.5.6 0.057 2.354 22.91 5.5.5 0.033 2.414 23.30 5.5.4 0.027 2.420 23.29 5.5.3 0.033 2.435 23.07 5.5.2 0.007 2.418 23.00 5.5.1 0.027 2.424 23.37 5.5.0 0.027 2.413 22.92 5.4.45 0.027 2.467 23.34 5.4.44 0.010 2.485 23.00 5.4.43 0.017 2.407 23.18 5.4.42 0.010 2.472 23.21 5.4.41 0.010 2.416 23.15 5.4.40 0.017 2.430 23.21 5.4.39 0.003 2.347 22.85 5.4.38 0.023 2.428 23.22 5.4.37 0.030 2.365 23.20 5.4.36 0.013 2.415 23.15 5.4.35 0.027 2.399 23.25 5.4.34 0.058 2.228 23.22 5.4.33 0.043 2.348 22.77 5.4.32 0.040 2.356 23.02 5.4.31 0.040 2.390 22.92 5.4.30 0.017 2.443 23.13 5.4.29 0.050 2.382 22.86 5.4.28 0.030 2.407 23.04 5.4.27 0.037 2.412 23.06 5.4.26 0.047 2.427 22.79 5.4.25 0.074 2.275 23.34 5.4.24 0.030 2.424 23.16 5.4.23 0.053 2.253 22.90 5.4.22 0.033 2.427 23.32 5.4.21 0.037 2.370 23.11 5.4.20 0.033 2.431 23.13 5.4.19 0.040 2.441 23.03 5.4.18 0.030 2.437 23.15 5.4.17 0.027 2.425 23.09 5.4.16 0.017 2.445 22.91 5.4.15 0.040 2.413 22.98 5.4.14 0.043 2.359 23.14 5.4.13 0.043 2.409 22.92 5.4.12 0.043 2.436 23.17 5.4.11 0.037 2.422 22.99 5.4.10 0.046 2.395 23.14 5.4.9 0.063 2.377 23.16 5.4.8 0.041 2.392 23.30 5.4.7 0.033 2.419 23.17 5.4.6 0.040 2.418 23.26 5.4.5 0.030 2.426 22.77 5.4.4 0.037 2.450 23.08 5.4.3 0.027 2.421 23.36 5.4.2 0.023 2.441 23.16 5.4.1 0.036 2.391 23.25 5.4.0 0.027 2.413 23.24 5.3.29 0.000 2.363 11.18 5.3.28 0.003 2.476 11.18 5.3.27 0.006 2.433 11.18 5.3.26 0.003 2.477 11.18 5.3.25 0.003 2.390 11.18 5.3.24 0.010 2.489 11.18 5.3.23 0.010 2.412 11.18 5.3.22 0.010 2.317 11.18 5.3.21 0.003 2.428 11.18 5.3.20 0.000 2.473 11.18 5.3.19 0.000 2.467 11.18 5.3.18 0.013 2.440 11.18 5.3.17 0.003 2.466 11.18 5.3.16 0.000 2.427 11.18 5.3.15 0.010 2.457 11.18 5.3.14 0.000 2.419 11.18 5.3.13 0.003 2.430 11.18 5.3.12 0.003 2.456 11.18 5.3.11 0.009 2.457 11.18 5.3.10 0.003 2.421 11.18 5.3.9 0.007 2.384 11.18 5.3.8 0.000 2.495 11.18 5.3.7 0.007 2.339 11.18 5.3.6 0.003 2.441 11.18 5.3.5 0.007 2.472 11.18 5.3.4 0.000 2.448 11.18 5.3.3 0.010 2.490 11.18 5.3.2 0.007 2.413 11.18 5.3.1 0.007 2.491 11.18 5.3.0 0.007 2.490 11.18
preferences:dark mode live preview
51.81 ms | 401 KiB | 5 Q