Jump to content

Code optimization


freeloader

Recommended Posts

Hi guys,

 

I have a code that gets connects with a webserver through cURL, and retrieves a page with a table. I need only 2 columns, but i need them linked together. I use a global var for that and store it as $globalvar[element1] = 'element2'; the way I go through the result of the webpage is with preg_match_all. Is preg_match_all the fastest solution in this case? Sometimes it needs to do over 1000 pages in a row so i'm really looking for the fastest way here :)

 

Thanks in advance.

Link to comment
https://forums.phpfreaks.com/topic/37968-code-optimization/
Share on other sites

I am not quite getting what you are asking...

 

Are just retrieing the source html from a file and parsing it? or is this curl request returning query results from another database table...

 

Could just be me but I don't think your question is very well explained.

Link to comment
https://forums.phpfreaks.com/topic/37968-code-optimization/#findComment-182335
Share on other sites

I doubt you'll get faster than a regular expression.  Parsing the document will take much longer.  And ereg is slower than preg, so you've made the right choice there :)

 

The only way I can imagine you might do it faster would be by making an educated guess and truncating the document before you do the matching.  You may be able to safely remove some data from the front and end.  As always, benchmark any change to see if you actually made it slower by trying to be too smart :)

Link to comment
https://forums.phpfreaks.com/topic/37968-code-optimization/#findComment-182338
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.