Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:20091 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 13625 invoked by uid 1010); 17 Nov 2005 09:14:06 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 13610 invoked from network); 17 Nov 2005 09:14:06 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Nov 2005 09:14:06 -0000 X-Host-Fingerprint: 195.80.104.106 gw.mig.ee Received: from ([195.80.104.106:18734] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id 97/9A-07637-DD94C734 for ; Thu, 17 Nov 2005 04:14:05 -0500 Message-ID: <97.9A.07637.DD94C734@pb1.pair.com> To: internals@lists.php.net Date: Thu, 17 Nov 2005 11:14:08 +0200 User-Agent: Mozilla Thunderbird 1.0.6 (X11/20050809) X-Accept-Language: en-us, en MIME-Version: 1.0 References: <97.19.07637.3993C734@pb1.pair.com> In-Reply-To: <97.19.07637.3993C734@pb1.pair.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Posted-By: 195.80.104.106 Subject: Re: a performance question From: ants.aasma@mig.ee (Ants Aasma) 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