<?php
$var = null;
$var = new stdClass();
$time1 = microtime(true);
for ($i = 0; $i <= 1000000; $i++) {
if (!$var) {}
}
$time1 = microtime(true) - $time1;
//echo "Time using '!': $time1\n";
$time2 = microtime(true);
for ($i = 0; $i <= 1000000; $i++) {
if ($var === null) {}
}
$time2 = microtime(true) - $time2;
//echo "Time using '===': $time2\n";
if ($time1 > $time2)
echo '"===" was faster';
else
echo ' "!" was faster';
- Output for 4.3.0 - 4.3.2, 4.3.4, 4.3.10 - 4.3.11, 4.4.1 - 4.4.2, 4.4.4 - 4.4.6, 4.4.8 - 4.4.9, 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.24 - 5.5.35, 5.6.8 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.17 - 7.2.25, 7.3.0 - 7.3.12, 7.4.0
- "===" was faster
- Output for 4.3.3, 4.3.5 - 4.3.9, 4.4.0, 4.4.3, 4.4.7
- "!" was faster
preferences:
151.54 ms | 402 KiB | 205 Q