Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 0.6.3

Bug #2566 _process() is extremely slow
Submitted: 2004-10-19 10:49 UTC
From: joern_h at gmx dot net Assigned: darkelder
Status: Closed Package: Mail_Mbox
PHP Version: 4.3.8 OS: Win 2000
Roadmaps: (Not assigned)    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 23 + 8 = ?

 
 [2004-10-19 10:49 UTC] joern_h at gmx dot net
Description: ------------ _process() reads the mbox file character by character and is extremely slow. Loading a ~4MB file took about 20 seconds. I rewrote the _process() function to read the file linewise, after that change loading that file took about 1 second. The source code for the new function is attached. Reproduce code: --------------- function _process($resourceId) { $fp = $this->_resources[$resourceId]['fresource']; // sanity check if (!is_resource($fp)) { return PEAR::raiseError("Resource isn't valid."); } // going to start if (@fseek($fp) == -1) { return PEAR::raiseError("Cannot read mbox"); } $start = 0; $laststart = 0; while ($line = fgets($fp, 4096)) { if (0 === strncmp($line, 'From ', 5)) { $laststart = $start; $start = ftell($fp) - strlen($line); if ($start > 0) { $this->_resources[$resourceId]["messages"][] = array($laststart, $start-1); } } } if ($start > 0) { $this->_resources[$resourceId]["messages"][] = array($start, ftell($fp)); } }

Comments

 [2004-10-19 16:26 UTC] User who submitted this comment has not confirmed identity
If you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE.  Write a message to pear-dev@lists.php.net
to request the confirmation link.  All bugs/comments/patches associated with this

email address will be deleted within 48 hours if the account request is not confirmed!
 [2004-10-20 05:41 UTC] User who submitted this comment has not confirmed identity
If you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE.  Write a message to pear-dev@lists.php.net
to request the confirmation link.  All bugs/comments/patches associated with this

email address will be deleted within 48 hours if the account request is not confirmed!