ID:               45409
 Updated by:       [EMAIL PROTECTED]
 Reported By:      jerico dot dev at gmail dot com
-Status:           Open
+Status:           Assigned
 Bug Type:         Performance problem
 Operating System: Windows XP SP3
 PHP Version:      5.2.6
-Assigned To:      
+Assigned To:      derick
 New Comment:

I'll have a look at this, but there is even a MUCH faster way:

<?php
$d = new DateTime( '1902-03-25 18:25:25' );
$mt0 = microtime(true);

$d->modify( '+1 year' );
$mt1 = microtime(true);
$d->modify( '+1 year' );
$mt2 = microtime(true);
printf("%.6f\r\n%.6f\r\n", $mt1-$mt0, $mt2-$mt1);
?>
0.013312/0.696215 for your code, vs 0.000065/0.000028 for my approach.


Previous Comments:
------------------------------------------------------------------------

[2008-07-01 20:55:08] jerico dot dev at gmail dot com

Description:
------------
strtotime() performs 3 orders of magnitude slower when operating on a
timestamp.

Reproduce code:
---------------
$string = '1902-03-25 18:25:25';
$timestamp = strtotime($string); 

$mt0 = microtime(true);
$result1 = strtotime("$string +1 year");
$mt1 = microtime(true);
$result2 = strtotime("+1 year", $timestamp);
$mt2 = microtime(true);
printf("%.6f\r\n%.6f\r\n", $mt1-$mt0, $mt2-$mt1);

// This will output
// 0.000171
// 0.721877
// on my machine

Actual result:
--------------
see reproduce code


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=45409&edit=1

Reply via email to