php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #63666 Poor date() performance [PATCH]
Submitted: 2012-12-02 00:50 UTC Modified: -
Votes:2
Avg. Score:3.5 ± 0.5
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:2 (100.0%)
From: njaguar at gmail dot com Assigned:
Status: Closed Package: Performance problem
PHP Version: 5.4.9 OS: any
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: njaguar at gmail dot com
New email:
PHP Version: OS:

 

 [2012-12-02 00:50 UTC] njaguar at gmail dot com
Description:
------------
Full info here:
http://news.php.net/php.internals/64127

4.4.9 on old machine vs 5.4.9 on new machine:
date                    : 1.856 sec	date                    : 2.111 sec

after patch (~20% performance increase):
date: 1.763 sec

* new machine is 2 to 200x faster than old machine, see link above for more details


Test script:
---------------
// common date output format

// use any preferred timing methods either within php, or externally time execution of the script (eg, microtime(), etc) -- the former will be more accurate at isolating the date() function, overall
$c = 1000000;
for($i=0; $i<$c; $i++) date('F j, Y, g:i a', $now);


Expected result:
----------------
worse performance on stock builds, better when patch is applied -- still considerably slower than 4.4.9 version of date() and related, but is an improvement

Actual result:
--------------
By moving the frequently used iso fetching function into the switch statement, this prevents an otherwise unnecessary step for other more common usages of date formatting.

Patches

date.patch (last revision 2012-12-02 00:50 UTC by njaguar at gmail dot com)

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-12-05 05:03 UTC] stas@php.net
Automatic comment on behalf of stas
Revision: http://git.php.net/?p=php-src.git;a=commit;h=fd650ec93e15bbbc05542e4acdde13d1fd9bcf73
Log: fix bug #63666 - Poor date() performance
 [2012-12-05 05:03 UTC] stas@php.net
-Status: Open +Status: Closed
 [2012-12-19 17:55 UTC] derick@php.net
Automatic comment on behalf of stas
Revision: http://git.php.net/?p=php-src.git;a=commit;h=fd650ec93e15bbbc05542e4acdde13d1fd9bcf73
Log: fix bug #63666 - Poor date() performance
 [2014-10-07 23:20 UTC] stas@php.net
Automatic comment on behalf of stas
Revision: http://git.php.net/?p=php-src-security.git;a=commit;h=fd650ec93e15bbbc05542e4acdde13d1fd9bcf73
Log: fix bug #63666 - Poor date() performance
 [2014-10-07 23:31 UTC] stas@php.net
Automatic comment on behalf of stas
Revision: http://git.php.net/?p=php-src-security.git;a=commit;h=fd650ec93e15bbbc05542e4acdde13d1fd9bcf73
Log: fix bug #63666 - Poor date() performance
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 11:01:29 2024 UTC