- microtime: documentation ( source)
<?php
$isset = true;
$array = array();
$notSetArray = array(0=>'');
$string = '';
// Test Source
function TestEmpty() {
$array = null;
$i = 0;
/* The Test */
$t = microtime(true);
while($i < 2000) {
!empty($array);
++$i;
}
echo (microtime(true) - $t);
}
function TestEmpty2() {
$array = null;
$i = 0;
/* The Test */
$t = microtime(true);
while($i < 2000) {
(! $array );
++$i;
}
echo (microtime(true) - $t);
}
function TestEmpty3() {
$array = null;
$i = 0;
/* The Test */
$t = microtime(true);
while($i < 2000) {
($array != []);
++$i;
}
echo (microtime(true) - $t);
}
function TestEmpty4() {
$array = null;
$i = 0;
/* The Test */
$t = microtime(true);
while($i < 2000) {
(gettype($array) === "array");
++$i;
}
echo (microtime(true) - $t);
}
function TestEmpty5() {
$array = null;
$i = 0;
/* The Test */
$t = microtime(true);
while($i < 2000) {
is_array($array);
++$i;
}
echo (microtime(true) - $t);
}
TestEmpty();
echo "\n\n";
TestEmpty2();
echo "\n\n";
TestEmpty3();
echo "\n\n";
TestEmpty4();
echo "\n\n";
TestEmpty5();