#23721 [NEW]: TRUE and FALSE constants slower than keywords in previous versions
| From: | max at fuck dot org | Date: | Tue, 20 May 2003 16:43:18 +0000 |
| Subject: | #23721 [NEW]: TRUE and FALSE constants slower than keywords in previous versions | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-40070@lists.php.net to get a copy of this message | ||
From: max at fuck dot org
Operating system: FreeBSD
PHP version: 4.3.1
PHP Bug Type: Performance problem
Bug description: TRUE and FALSE constants slower than keywords in previous versions
-bash-2.05b$ cat true_test.php
<?php /* -*- C++ -*- */
function getmicrotime(){
list($usec, $sec) = explode(" ",microtime());
return ((float)$usec + (float)$sec);
}
$time_start = getmicrotime();
for ($i = 0; $i <= 1000000; $i++) {
if ($i % 2) {
$n = true;
}
else {
$n = false;
}
if ($n == true) {
}
else if ($n == false) {
}
}
$time_end = getmicrotime();
$time = $time_end - $time_start;
echo "true/false:\t $time seconds.\n";
$time_start = getmicrotime();
for ($i = 0; $i <= 1000000; $i++) {
if ($i % 2) {
$n = TRUE;
}
else {
$n = FALSE;
}
if ($n == TRUE) {
}
else if ($n == FALSE) {
}
}
$time_end = getmicrotime();
$time = $time_end - $time_start;
echo "TRUE/FALSE:\t $time seconds.\n";
?>
-bash-2.05b$ php -v
4.2.3
-bash-2.05b$ uname -a
FreeBSD 4.8-RELEASE FreeBSD 4.8-RELEASE #0: Thu Apr 3 10:53:38 GMT 2003
-bash-2.05b$ php true_test.php
X-Powered-By: PHP/4.2.3
Content-type: text/html
true/false: 5.9379440546036 seconds.
TRUE/FALSE: 5.9383209943771 seconds.
<configure/make/make install-cli 4.3.1 (no special config options)>
-bash-2.05b$ php -v
PHP 4.3.1 (cli) (built: May 20 2003 11:15:26)
Copyright (c) 1997-2002 The PHP Group
Zend Engine v1.3.0, Copyright (c) 1998-2002 Zend Technologies
-bash-2.05b$ php true_test.php
true/false: 4.2005170583725 seconds.
TRUE/FALSE: 5.1550530195236 seconds.
<configure/make/make install-cli latest snapshot (no special config
options)>
PHP 4.3.2RC4-dev (cli) (built: May 20 2003 11:41:28)
Copyright (c) 1997-2003 The PHP Group
Zend Engine v1.3.0, Copyright (c) 1998-2003 Zend Technologies
-bash-2.05b$ php true_test.php
true/false: 4.2775070667267 seconds.
TRUE/FALSE: 5.1591459512711 seconds.
I've tested this on multiple machines, seems that anything newer than
4.3.0 has this issue. Although I haven't looked myself I was told that
recently TRUE and FALSE are now defined as constants rather than keywords.
While these are both faster than the previous version(s), if this
difference in speed was intended, it wasn't documented anywhere.
--
Edit bug report at http://bugs.php.net/?id=23721&edit=1
--
Try a CVS snapshot: http://bugs.php.net/fix.php?id=23721&r=trysnapshot
Fixed in CVS: http://bugs.php.net/fix.php?id=23721&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=23721&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=23721&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=23721&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=23721&r=support
Expected behavior: http://bugs.php.net/fix.php?id=23721&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=23721&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=23721&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=23721&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=23721&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=23721&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=23721&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=23721&r=gnused