From:             r dot craig at chester dot ac dot uk
Operating system: Linux 2.6.5-7.282-bigsmp
PHP version:      5.2.0
PHP Bug Type:     Performance problem
Bug description:  Large Memory Usage and Slowness on strtotime() 

Description:
------------
Performance of the attached script is 10 times slower and uses 30 times as
much memory as it does on PHP 5.1.6.

I am not sure if it is strtotime(), this is where I first noticed the
problem. And if i take out the strtotime(), it is fine. However
strtotime() does not in itself take any longer.

Configure Command =>  './configure' '--with-freetype'
'--with-apxs2=/usr/sbin/apxs2' '--with-mssql' '--with-gettext'
'--with-ldap' '--with-pspell' '--enable-s
hared' '--with-jpeg-dir=/usr' '--enable-gd-native--ttf' '--with-zlib'
'--enable-magic-quotes' '--with-openssl' '--with-mysqli' '--with-mysql'
'--enable-memory
-limit' '--with-tidy=/usr/src/tidy'
'--with-config-file-path=/usr/local/Zend/etc/' '--enable-soap'
Server API => Command Line Interface


Reproduce code:
---------------
<?php

print_mem();
$t= return_some_stuff(); /** remove the assignment this is fine
performance wise, but still uses memory */

$start = microtime(true); $count =4;

print_mem();

for($i=0; $i<$count; $i++) test1();

$diff = microtime(true) - $start;
echo "Total Time: $diff ms ($count) , avergage: " .($diff/$count) . 
"<br/>\n\n"; print_mem();

function test1(){
        for($i=0; $i<3000; $i++){
            strtotime ('2005-09-01');
  /** if i take out the strtotime, or change it to microtime() or some
other NDF, performance is fine */
        }
}
function return_some_stuff () {
        for($i=0; $i<4000; $i++){
        $x[$i]["FOOBARFOOBAR"]="FOOBAR";
    }

        foreach ($x as $tmp) {
        $element[] = $tmp['FOOBARFOOBAR'];
        }
        return $element;
}

function print_mem(){
        $mem = memory_get_usage();
        $mem_peak = function_exists('memory_get_peak_usage')?
memory_get_peak_usage():$mem;
        printf("MEM %.2fMB (%.2fMB)\n\n", $mem/1024/1024,
$mem_peak/1024/1024 ); }
?>


Expected result:
----------------
(As on PHP 5.1.6)

MEM 0.06MB (0.06MB)

MEM 0.31MB (0.31MB)

Total Time: 0.24065089225769 ms (4) , average: 0.060162723064423

MEM 0.31MB (0.31MB)


Actual result:
--------------
On php 5.2.0 

MEM 0.06MB (0.06MB)

MEM 0.39MB (1.19MB)

Total Time: 2.4987750053406 ms (4) , average: 0.62469375133514<br/>

MEM 9.23MB (9.23MB)


-- 
Edit bug report at http://bugs.php.net/?id=40363&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=40363&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=40363&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=40363&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=40363&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=40363&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=40363&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=40363&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=40363&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=40363&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=40363&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=40363&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=40363&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=40363&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=40363&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=40363&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=40363&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=40363&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=40363&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=40363&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=40363&r=mysqlcfg

Reply via email to