Previous Entry Share Next Entry
Computing cost and elapsed time
Default
gemsling
Okay, I admit that opening a file 14334 times to see if it has a line matching the current item may not be the most efficient thing to do. In hindsight, reading the whole 2396 line data set (432 Kb) into memory might have been a better thing to do. *Taps watch*

3200 lines done so far. Time to check that I'm not "while"ing my way through every line after a match is found... Hmm, it seems that I am. Just in case an item is in there twice, though it shouldn't be. Meh. I think I'll leave it, just in case.
Tags:

  • 1
Newbie regexp question. If I'm looking for "foo" at the start of the line, with something like this:

$found = "1", if /^($item):text/i;

...is perl smart enough to stop searching if the first letter is not 'f'? (I suspect that it is, but also that it makes little difference, as the cost comes from reading from the file, not comparing strings in memory.)

  • 1
?

Log in