$end); } function Test1_2() { global $aHash; /* The Test */ $t = microtime(true); while(list(,$val) = each($aHash)); $end = (microtime(true) - $t); return array('while(list(,$val) = each($aHash));'=>$end); } function Test1_3() { global $aHash; /* The Test */ $t = microtime(true); foreach($aHash as $key => $val); $end = (microtime(true) - $t); return array('foreach($aHash as $key => $val);'=>$end); } function Test1_4() { global $aHash; /* The Test */ $t = microtime(true); while(list($key,$val) = each($aHash)); $end = (microtime(true) - $t); return array('while(list($key,$val) = each($aHash));'=>$end); } function Test1_5() { global $aHash; /* The Test */ $t = microtime(true); foreach($aHash as $key=>$val) $tmp[] = $aHash[$key]; $end = (microtime(true) - $t); return array('foreach($aHash as $key=>$val) $tmp[] = $aHash[$key];'=>$end); } // Test Source function Test1_6() { global $aHash; /* The Test */ $t = microtime(true); while(list($key) = each($aHash)) $tmp[] = $aHash[$key]; $end = (microtime(true) - $t); return array('while(list($key) = each($aHash)) $tmp[] = $aHash[$key];'=>$end); } function Test1_7() { global $aHash; /* The Test */ $t = microtime(true); foreach($aHash as $key[] => $val[]); $end = (microtime(true) - $t); return array('foreach($aHash as $key[] => $val[]);'=>$end);; } function Test1_8() { global $aHash; /* The Test */ $t = microtime(true); array_keys($aHash); array_values($aHash); $end = (microtime(true) - $t); return array('array_keys($aHash); array_values($aHash);'=>$end); } // Test Source function Test1_9() { global $aHash; /* The Test */ $t = microtime(true); $key = array_keys($aHash); $size = sizeOf($key); for ($i=0; $i<$size; $i++) $tmp[] = $aHash[$key[$i]]; $end = (microtime(true) - $t); return array('for ($i=0; $i<$size; $i++) $tmp[] = $aHash[$key[$i]];'=>$end); } // Test Source function Test1_10() { global $aHash; /* The Test */ $t = microtime(true); $keys=$vals=array(); while(list($key,$val) = each($aHash)); {$keys[]=$key; $vals[]=$val;} $end = (microtime(true) - $t); return array('$keys=$vals=array(); while(list($key,$val) = each($aHash)) {$keys[]=$key; $vals[]=$val;}'=>$end); } // Variable Clean-up function Test1_End() { global $aHash; unset($aHash); } function Test2_Start(){Test1_Start(); return 'foreach() vs. for vs. while(list() = each()) ';} function Test2_End(){return Test1_Start();} function Test2_1() { global $aHash; /* The Test */ $t = microtime(true); foreach($aHash as $key=>$val) $aHash[$key] .= "a"; $end = (microtime(true) - $t); return array('foreach($aHash as $key=>$val) $aHash[$key] .= "a";'=>$end); } function Test2_2() { global $aHash; /* The Test */ $t = microtime(true); while(list($key) = each($aHash)) $aHash[$key] .= "a"; $end = (microtime(true) - $t); return array('while(list($key) = each($aHash)) $aHash[$key] .= "a";'=>$end); } function Test2_3() { global $aHash; /* The Test */ $t = microtime(true); $key = array_keys($aHash); $size = sizeOf($key); for ($i=0; $i<$size; $i++) $aHash[$key[$i]] .= "a"; $end = (microtime(true) - $t); return array('for ($i=0; $i<$size; $i++) $aHash[$key[$i]] .= "a";'=>$end); } function Test3_Start(){ global $aHash; $i = 0; $tmp = ''; while($i < 10000) { $tmp .= 'a'; ++$i; } $aHash = array_fill(5, 100000, $tmp); unset($i, $tmp); return 'For-loop'; } // Test Source function Test3_1() { global $x; /* The Test */ $t = microtime(true); $size = count($x); for ($i=0; $i<$size; $i++); $end = (microtime(true) - $t); return array('$size = count($x); for ($i=0; $i<$size; $i++);' => $end); } // Test Source function Test3_2() { global $x; /* The Test */ $t = microtime(true); for ($i=0; $i $end); } function Test3_3() { global $x; /* The Test */ $t = microtime(true); $size = sizeof($x); for ($i=0; $i<$size; $i++); $end = (microtime(true) - $t); return array('$size = sizeof($x); for ($i=0; $i<$size; $i++);' => $end); } function Test3_4() { global $x; /* The Test */ $t = microtime(true); for ($i=0; $i $end); } // Variable Clean-up function Test3_End() { global $x, $aHash; unset($x, $aHash); } // Echo function Test11_Start(){return 'Echo / Print';} function Test11_1() { global $answer; /* The Test */ ob_start(); $t = microtime(true); while($i < 1000) { echo 'aaaaaaa'.'aaaaaaa'.'aaaaaaa'.'aaaaaaa'; ++$i; } $end = microtime(true) - $t; ob_end_clean(); return array("echo 'aaaaaaa'.'aaaaaaa'.'aaaaaaa'.'aaaaaaa';" => $end); } function Test11_2() { global $answer; /* The Test */ ob_start(); $t = microtime(true); while($i < 1000) { echo 'aaaaaaa','aaaaaaa','aaaaaaa','aaaaaaa'; ++$i; } $end = microtime(true) - $t; ob_end_clean(); return array("echo 'aaaaaaa','aaaaaaa','aaaaaaa','aaaaaaa';" => $end); } function Test11_3() { global $answer; /* The Test */ ob_start(); $t = microtime(true); while($i < 1000) { print 'aaaaaaa'.'aaaaaaa'.'aaaaaaa'.'aaaaaaa'; ++$i; } $end = microtime(true) - $t; ob_end_clean(); return array("print 'aaaaaaa'.'aaaaaaa'.'aaaaaaa'.'aaaaaaa';" => $end); } function Test11_4() { global $answer; /* The Test */ ob_start(); $t = microtime(true); while($i < 1000) { $a = 'aaaaaaa'; echo $a.$a.$a.$a; ++$i; } $end = microtime(true) - $t; ob_end_clean(); return array('$a'." = 'aaaaaaa'; echo ".'$a.$a.$a.$a;' => $end); } function Test11_5() { global $answer; /* The Test */ ob_start(); $t = microtime(true); while($i < 1000) { $a = 'aaaaaaa'; echo $a,$a,$a,$a; ++$i; } $end = microtime(true) - $t; ob_end_clean(); return array('$a'." = 'aaaaaaa'; echo ".'$a,$a,$a,$a;' => $end); } function Test11_6() { global $answer; /* The Test */ ob_start(); $t = microtime(true); while($i < 1000) { $a = 'aaaaaaa'; print $a.$a.$a.$a; ++$i; } $end = microtime(true) - $t; ob_end_clean(); return array('$a'." = 'aaaaaaa'; print ".'$a.$a.$a.$a;' => $end); } // Variable Clean-up function Test11_End() { global $answer; unset($answer); } echo ' '; $arr = array(1, 2, 3, 11); while(list(,$a) = each($arr)){ $test = 'Test'.$a.'_'; $start = $test.'Start'; $end = $test.'End'; echo '

'.$start().'

'; echo ''; $b=1; $tests = array(); while(function_exists($test.$b)){ $start(); $letest = $test.$b; list($cle,$val) = each($letest()); $tests[$cle] = $val; $end(); $b++; } $min = min(array_values($tests)); asort($tests); while (list($cle,$val) = each($tests)){ echo ''; } echo '
OpérationTemps%
'.htmlentities($cle).''.number_format($val, 8, ',', ' ').''.(int)($val / $min * 100).'
'; $a++; } echo ''; ?>