PHP 4.0 Bug #6608 Updated: sizeof($array) extremly slow in loop. 90% cpu util

From: Date: Sat, 16 Sep 2000 22:12:20 +0000
Subject: PHP 4.0 Bug #6608 Updated: sizeof($array) extremly slow in loop. 90% cpu util
Groups: php.dev 
Request: Send a blank email to php-dev+get-33359@lists.php.net to get a copy of this message
ID: 6608 Updated by: stas Reported By: mledet@spirenet.com Status: Open Bug Type: Performance problem Assigned To: Comments: Previous Comments: --------------------------------------------------------------------------- [2000-09-07 13:01:24] mledet@spirenet.com The following code performed well under 3.0.16. for ($i=0; $i < sizeof($teacherarray); $i++) { $a=$teacher_array[$i]; if ($a->teacher_id==$teacher_id) { break; } } However, under php 4.0.2 it is extrememly slow and causes cpu util for the httpd process to hit 90%. $teacherarray is not being modified during the loop so the condition isn't changing. BTW: Changing to the following code works ok. $numteachers = sizeof($teacherarray); for ($i=0; $i < $numteachers; $i++) { $a=$teacher_array[$i]; if ($a->teacher_id==$teacher_id) { break; } } Either the sizeof function has had a serious decrease in its speed or something is awry.. --------------------------------------------------------------------------- Full Bug description available at: http://bugs.php.net/?id=6608

« previous php.dev (#33359) next »