ID:               40261
 User updated by:  thuejk at gmail dot com
 Reported By:      thuejk at gmail dot com
-Status:           Feedback
+Status:           Open
 Bug Type:         Performance problem
 Operating System: Linux
 PHP Version:      5.2.0
 New Comment:

I have made it a bit shorter.

I left the DebugStats class in, it is useful. Just treat it as a black
box. I can garantie that the two calls into it does not account for the
8 seconds performance problem...


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

[2007-01-28 01:30:33] [EMAIL PROTECTED]

Could please modify the script, so that it would be _short_ but
complete?

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

[2007-01-28 01:25:13] thuejk at gmail dot com

I added the requested changes to the linked file
http://thuejk.dk/test.php.txt

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

[2007-01-28 01:15:25] [EMAIL PROTECTED]

Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc. If the script requires a 
database to demonstrate the issue, please make sure it creates 
all necessary tables, stored procedures etc.

Please avoid embedding huge scripts into the report.



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

[2007-01-28 00:30:02] thuejk at gmail dot com

Description:
------------
I have some code which produces unacceptible performance in a specific
situation. Making a completely trivial change improves performance a
hundred-fold or more.

The problem is 100% reproducible.

The code looks something like:

/* pseudocode*/
function get_data_from_pgsql(){
  ...
  $map = Array();
  foreach ($rows as $row) {
     $map = row[index];
  }
  return $map;
}
$data1 = get_data_from_pgsql
$data2 = get_data_from_pgsql

One run with 10000 rows of result took 8.77 seconds, which is clearly
silly. Making the extremely trivial change of moving the code block 
  foreach ($rows as $row) {
     $map = row[index];
  }
out of the function get_data_from_pgsql(), the code suddently only
takes 0.1 seconds to run (factor 90)! Having more rows in the result
makes the factor difference larger; it seems to increase
quadratically.

Not saving the return values in $data1 and $data2 also improves
performance immensely.

PHP 5.1.5 did not have this problem (or at least it was much smaller).

Reproduce code:
---------------
http://thuejk.dk/test.php.txt

You need a running postgresql database with one table, which has at
least 10000 entries.

change the line
  $translate_outside_function = false;
at the top of the file to see the difference mentioned above.



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


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

Reply via email to