|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2003-05-20 18:00 UTC] sniper@php.net
[2003-05-20 19:12 UTC] max at fuck dot org
[2003-05-20 20:08 UTC] sniper@php.net
[2003-05-21 02:01 UTC] philip@php.net
[2003-05-21 03:11 UTC] derick@php.net
[2003-05-21 08:57 UTC] max at fuck dot org
[2003-05-21 10:05 UTC] sniper@php.net
[2003-05-21 11:14 UTC] philip@php.net
[2004-02-17 22:16 UTC] irchtml@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 19 21:00:01 2025 UTC |
-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.