array(4) {
'array_key_exists' =>
double(0.76186203956604)
'isset' =>
double(0.78142905235291)
'noCheck' =>
double(0.80179715156555)
'empty' =>
double(0.80491018295288)
}
Null coallescent is not the better solution...
array(4) {
'array_key_exists' =>
double(0.76186203956604)
'isset' =>
double(0.78142905235291)
'noCheck' =>
double(0.80179715156555)
'empty' =>
double(0.80491018295288)
}
Null coallescent is not the better solution...
<?php | |
$a = []; | |
$result = []; | |
for($i=0;$i<20000000;$i++) | |
$a[sha1($i)] = sha1($i); | |
$numIterations = 10000000; | |
echo 'start test '.chr(10); | |
$start = microtime(true); | |
for ($i = 0; $i < $numIterations; $i++) { $a['none'] ?? ''; }; | |
$result['noCheck'] = microtime(true) - $start; | |
echo '2nd test '.chr(10); | |
$start = microtime(true); | |
for ($i = 0; $i < $numIterations; $i++) { empty($a['none']) ? '' : ''; }; | |
$result['empty'] = microtime(true) - $start; | |
echo '3rd test '.chr(10); | |
$start = microtime(true); | |
for ($i = 0; $i < $numIterations; $i++) { isset($a['none']) ? '' : ''; }; | |
$result['isset'] = microtime(true) - $start; | |
echo '4th test '.chr(10); | |
$start = microtime(true); | |
for ($i = 0; $i < $numIterations; $i++) { array_key_exists('none', $a) ? '' : ''; }; | |
$result['array_key_exists'] = microtime(true) - $start; | |
asort($result); | |
var_dump($result); |