ID: 46926 User updated by: for-bugs at hnw dot jp Reported By: for-bugs at hnw dot jp Status: Bogus Bug Type: Performance problem Operating System: * PHP Version: 5.2.8 Assigned To: derick New Comment:
I noticed this is fixed on PHP 5.2.10. Thanks a lot. Previous Comments: ------------------------------------------------------------------------ [2009-03-22 00:15:48] for-bugs at hnw dot jp This bug is not same as #45822. This report explains the problem about the performece of mktime(), while #45822 is about endless loop in datetime parser. Martin's patch looks like good, but is not perfect. There are still slow examples. Such as: <?php gmmktime(0,0,0,1-12*(int)(2147483647/12),1,1970+(int)(2147483647/12)); ------------------------------------------------------------------------ [2009-03-10 22:41:58] scott...@php.net Duplicate of bug #45822 ------------------------------------------------------------------------ [2009-03-10 18:55:53] mmcnicklebugs at googlemail dot com [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 ------------------------------------------------------------------------ [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