View Single Post
Old 12-06-2004, 05:19 PM   #7 (permalink)
idx
Senior Grasshopper
 
idx's Avatar
 
Join Date: Jun 2003
Location: FL
Posts: 317
idx is on a distinguished road
Quote:
Originally Posted by Rafkin
so question is, should i pass something that big as one string, using the multi-line option in the regex? or should i pass that one line at a time? Wich would be faster, or more optimized?
Without running a few timing tests (after the full highlighter is created) I don't know. For my above snippet, I passed the entire script as a string (without specifying a multi-line match) and it seemed to work.

I'd start off with passing the entire thing as a string and measure the time with the microtime function. (something like the microtime_float example)

Time it for awhile, maybe 10 runs and get an average, then change the script around to read the file line by line and process each separately.

If the preg_replace method seems fast enough on your large file (34.5k), then I wouldn't even worry about going line by line. Although, if you have time and want to test it out, it might be interesting to hear which is faster.. (might only make a difference when the files get very large.)

-r
idx is offline   Reply With Quote