#34700 [Fbk]: performance problem with date()
| From: | rasmus@php.net | Date: | Sat, 01 Oct 2005 15:15:20 +0000 |
| Subject: | #34700 [Fbk]: performance problem with date() | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-85853@lists.php.net to get a copy of this message | ||
ID: 34700
Updated by: rasmus@php.net
Reported By: six at aegis-corp dot org
Status: Feedback
Bug Type: Date/time related
Operating System: linux 2.4
PHP Version: 5.1.0RC1
New Comment:
One of the new things in PHP 5.1 is the $_SERVER['REQUEST_TIME']
variable that gets set to the request time. When running under Apache
this comes directly from the time syscall Apache makes for every
request, so by using this you can actually eliminate any time-related
syscalls at the PHP level and still do time stuff in a PHP script. But
yes, it looks like there are a few things that can be cleaned up here.
Previous Comments:
------------------------------------------------------------------------
[2005-10-01 17:05:36] sniper@php.net
Please try using this CVS snapshot:
http://snaps.php.net/php5-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php5-win32-latest.zip
------------------------------------------------------------------------
[2005-10-01 16:07:27] six at aegis-corp dot org
Description:
------------
performance of the date() function has taken a huge hit between PHP 5.0
and 5.1. i believe this is because of an unneeded syscall when a second
argument is given.
Reproduce code:
---------------
<?
for ($a = 0; $a < 100000; $a++) date("Y-m-d H:i:s", $a);
?>
Expected result:
----------------
time /usr/local/bin/php-cli-5.0.4 datetest.php
real 0m2.022s
user 0m1.910s
sys 0m0.000s
Actual result:
--------------
time /usr/local/bin/php-cli-5.1.0RC1 datetest.php
real 0m10.001s
user 0m8.120s
sys 0m0.130s
5.1.0 takes more than 4x the time to complete than 5.0.4
with an strace, I can see that 5.1.0RC1 makes one (probably unneeded)
time() syscall per call to date(), which 5.0.4 does not
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=34700&edit=1