<?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.1 - 4.3.3, 4.3.6, 4.3.8, 4.4.3, 4.4.6 - 4.4.7, 5.0.0 - 5.0.5, 5.1.0 - 5.1.4, 5.1.6, 5.2.1 - 5.2.13, 5.2.15 - 5.2.17, 5.3.0 - 5.3.9, 5.3.11 - 5.3.29, 5.4.0 - 5.4.1, 5.4.3 - 5.4.4, 5.4.6 - 5.4.19, 5.4.21 - 5.4.45, 5.5.0 - 5.5.20, 5.5.22 - 5.5.27, 5.5.29 - 5.5.31, 5.5.33 - 5.5.38, 5.6.0 - 5.6.3, 5.6.5 - 5.6.28, 7.0.0 - 7.0.4, 7.0.6 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.25, 7.3.0 - 7.3.5, 7.3.7 - 7.3.12, 7.4.0
- "===" was faster
- Output for 4.3.0, 4.3.4 - 4.3.5, 4.3.7, 4.3.9 - 4.3.11, 4.4.0 - 4.4.2, 4.4.4 - 4.4.5, 4.4.8 - 4.4.9, 5.1.5, 5.2.0, 5.2.14, 5.3.10, 5.4.2, 5.4.5, 5.4.20, 5.5.21, 5.5.28, 5.5.32, 5.6.4, 7.0.5, 7.3.6
- "!" was faster
preferences:
194.19 ms | 404 KiB | 251 Q