Skip to content

Instantly share code, notes, and snippets.

@sun
Created September 11, 2012 03:14
Show Gist options
  • Save sun/3695687 to your computer and use it in GitHub Desktop.
Save sun/3695687 to your computer and use it in GitHub Desktop.
bench: Compare Boolean value to FALSE
> php bench.php
Peak memory before test: 422.43 KB
Iterations: 1,000,000
nothing: 0.2577 seconds
function no_op(): 1.4858 seconds
!$value: 0.3877 seconds
$value === FALSE: 0.3837 seconds
FALSE === $value: 0.3868 seconds
$value == FALSE: 0.3889 seconds
FALSE == $value: 0.3873 seconds
Peak memory after test: 422.43 KB
Memory difference: 0.00 KB
@chx
Copy link

chx commented Sep 11, 2012

Source? Also, the difference is so small it very well can be a measuring error. Did you try running this a couple times? The difference between === and == must be valid because == is a much more complex operation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment