Skip to content

Instantly share code, notes, and snippets.

@PyYoshi
Last active August 29, 2015 14:01
Show Gist options
  • Select an option

  • Save PyYoshi/864dc38fa82adc7cb8f8 to your computer and use it in GitHub Desktop.

Select an option

Save PyYoshi/864dc38fa82adc7cb8f8 to your computer and use it in GitHub Desktop.
<?php
$var = null;
$start1 = microtime(true);
$i = 0;
while($i < 10000000){
$ret1 = $var === null;
$i++;
}
$end1 = microtime(true);
$start2 = microtime(true);
$j = 0;
while($j < 10000000){
$ret2 = is_null($var);
$j++;
}
$end2 = microtime(true);
echo('PHP Version: ' . PHP_VERSION . PHP_EOL);
echo('=== null' . PHP_EOL);
echo($end1 - $start1 . PHP_EOL);
echo(PHP_EOL);
echo('is_null' . PHP_EOL);
echo($end2 - $start2 . PHP_EOL);
$ php ./null.php
PHP Version: 5.5.12
=== null
1.0364179611206
is_null
7.9186248779297
$ hhvm ./null.php
PHP Version: 5.5.99-hiphop
=== null
0.47122597694397
is_null
0.46273303031921
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment