php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #39968 date() is extremely slow
Submitted: 2006-12-27 22:32 UTC Modified: 2006-12-27 22:35 UTC
From: katzenmayer at erfnet dot de Assigned:
Status: Not a bug Package: Performance problem
PHP Version: 5.2.0 OS: Debian Sarge
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
35 - 35 = ?
Subscribe to this entry?

 
 [2006-12-27 22:32 UTC] 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


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-12-27 22:35 UTC] iliaa@php.net
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.
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Fri Aug 07 17:01:23 2020 UTC