Re: a performance question
| From: | Ants Aasma | Date: | Thu, 17 Nov 2005 09:14:08 +0000 |
| Subject: | Re: a performance question | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-20091@lists.php.net to get a copy of this message | ||
I'd say if anybody should know this for certain, it's somebody who bothers to benchmark it:
$ time php -r '$s="abc";for($i=0;$i<10000000;++$i);'
real 0m1.966s user 0m1.634s sys 0m0.072s$ time php -r '$s="abc";for($i=0;$i<10000000;++$i) $s=="abc";'
real 0m3.974s user 0m3.779s sys 0m0.062s$ time php -r '$s="abc";for($i=0;$i<10000000;++$i) $s==="abc";'
real 0m2.510s user 0m2.320s sys 0m0.056sAnts Ron Korving wrote:
If anybody should know this for certain, it's core developers, hence my question here. I'm curious if type certainty requires an extra check, or a check less. Which of these is faster? if ($str === 'abc') { } if ($str == 'abc') { } I expect the triple '=' to be faster, but I'd like to be sure. Thank you, Ron