#39968 [Opn->Bgs]: date() is extremely slow
ID: 39968
Updated by: iliaa@php.net
Reported By: katzenmayer at erfnet dot de
-Status: Open
+Status: Bogus
Bug Type: Performance problem
Operating System: Debian Sarge
PHP Version: 5.2.0
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
You need to set the timezone, otherwise a notice is raised
which is what's killing the speed of your code.
Previous Comments:
------------------------------------------------------------------------
[2006-12-27 22:32:23] katzenmayer at erfnet dot de
Description:
------------
While switching a calendar script from PHP4 to PHP5 I noticed the
script takes multiple times as long to complete in PHP5 than it did in
PHP4.
The problem seems to be date() and mktime() functions.
I did not notice any other PHP5 related performance issues. Scripts
that do not use date() or mktime() run very fast.
Reproduce code:
---------------
test.php:
<?
for ($i=0;$i<100000;$i++)
{
date('d');
}
?>
Now check this script with both PHP4 and PHP5:
time php4 test.php
time php5 test.php
Expected result:
----------------
The script should take about the same time in both PHP4 and PHP5
Actual result:
--------------
time php4 test.php
real 0m0.286s
user 0m0.034s
sys 0m0.252s
time php5 test.php
real 0m25.252s
user 0m18.579s
sys 0m5.615s
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=39968&edit=1
Thread (2 messages)