# a performance question

- Thread: https://externals.io/message/20088
- Original archive: https://news-web.php.net/php.internals/20088
- Started by Ron Korving on 2005-11-17T08:01:48+00:00
- Messages: 2
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · RFCs at https://externals.io/rfc.md · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #20088 — Ron Korving — 2005-11-17T08:01:48+00:00

URL: https://externals.io/message/20088#20088

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

---

## #20091 — Ants Aasma — 2005-11-17T09:14:08+00:00

URL: https://externals.io/message/20088#20091 · In reply to: #20088

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.056s

Ants

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
