ID: 46926
Comment by: mmcnicklebugs at googlemail dot com
Reported By: for-bugs at hnw dot jp
Status: Assigned
Bug Type: Performance problem
Operating System: *
PHP Version: 5.2.8
Assigned To: derick
New Comment:
[PATCH]
I've created a patch [1] which resolves the performance issue.
do_range_limit() did a naïve factoring approach when passed a negative
offset. I've implemented the same factoring that is used for positive
values. All the tests pass.
The patch is against CVS 5.3.
[1] http://whompbox.com/patches/php/tm2unixtime.patch
-- Martin McNickle
Previous Comments:
------------------------------------------------------------------------
[2008-12-22 14:01:51] for-bugs at hnw dot jp
I'm sorry, reproduce code depends on my timezone. Replace code as
below:
$unixtime = mktime(9,0,-2147483647,1,1,1970);
to
$unixtime = gmmktime(0,0,-2147483647,1,1,1970);
and
$unixtime = mktime(9,0,2147483646,1,1,1970);
to
$unixtime = gmmktime(0,0,2147483646,1,1,1970);
------------------------------------------------------------------------
[2008-12-22 13:55:06] for-bugs at hnw dot jp
Description:
------------
when it gots very small 3rd argument, mktime() performs 1000 times
slower than ordinary case.
Reproduce code:
---------------
<?php
$mt0 = microtime(true);
for($i=0;$i<10;$i++){
$unixtime = mktime(9,0,-2147483647,1,1,1970);
}
$mt1 = microtime(true);
for($i=0;$i<10;$i++){
$unixtime = mktime(9,0,2147483646,1,1,1970);
}
$mt2 = microtime(true);
printf("%.6f\n%.6f\n", $mt1-$mt0, $mt2-$mt1);
// This will output
// 5.139942
// 0.000707
// on my machine
Actual result:
--------------
see reproduce code
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=46926&edit=1