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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: katzenmayer at erfnet dot de
New email:
PHP Version: OS:

 

 [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

Pull Requests

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-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 11:01:30 2024 UTC