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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.