Bug #75088 [NEW]: getTransitions is slow with large values
| From: | gmblar+php at gmail dot com | Date: | Thu, 17 Aug 2017 20:10:41 +0000 |
| Subject: | Bug #75088 [NEW]: getTransitions is slow with large values | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-210723@lists.php.net to get a copy of this message | ||
From: gmblar+php at gmail dot com
Operating system: MacOS 10.13
PHP version: 7.1.8
Package: Date/time related
Bug Type: Bug
Bug description:getTransitions is slow with large values
Description:
------------
getTransitions is slow with large negative or positive values. With the
default values PHP_INT_MIN and PHP_INT_MAX the function takes a very
long time.
Test script:
---------------
<?php
function measure_duration(callable $callback) {
$start = microtime(true);
call_user_func($callback);
$duration = microtime(true) - $start;
printf("Duration: %s\n\n", number_format($duration, 6));
}
$timezone = new DateTimeZone('Europe/Berlin');
measure_duration(function() use($timezone) {
printf("Default Value\n");
$timezone->getTransitions();
});
measure_duration(function() use($timezone) {
$timestamp = 0;
printf("Timestamp for %s\n", date('Y-m-d H:i:s', $timestamp));
$timezone->getTransitions($timestamp);
});
measure_duration(function() use($timezone) {
$timestamp = -62135596800;
printf("Timestamp for %s\n", date('Y-m-d H:i:s', $timestamp));
$timezone->getTransitions($timestamp);
});
Expected result:
----------------
Default Value
Duration: 0.000268
Timestamp for 1970-01-01 00:00:00
Duration: 0.000134
Timestamp for 0001-01-01 00:00:00
Duration: 0.000161
Actual result:
--------------
Default Value
Duration: 0.018967
Timestamp for 1970-01-01 00:00:00
Duration: 0.000101
Timestamp for 0001-01-01 00:00:00
Duration: 0.000095
--
Edit bug report at https://bugs.php.net/bug.php?id=75088&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=75088&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=75088&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=75088&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=75088&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=75088&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=75088&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=75088&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=75088&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=75088&r=support
Expected behavior: https://bugs.php.net/fix.php?id=75088&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=75088&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=75088&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=75088&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=75088&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=75088&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=75088&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=75088&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=75088&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=75088&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=75088&r=mysqlcfg