|No such thing as a small change|
RE: Re: How To Do This Better?by ahunter (Monk)
|on Apr 15, 2000 at 00:14 UTC||Need Help??|
You probably meant to say:
As your original seems to give up at the first newline. Plus, you have to remember that perl compiles regular expressions to make them run faster, particularily when they don't require backtracking (basically creates a finite state machine to do the job). As these are executed in C, writing perl to do the same job is *always* going to be slower.
Plus getc() isn't exactly a star performer, either. Maybe use the unbuffered IO stuff if you want to improve performance in this area, though you'd really have to be after squeezing the last ounce of speed out of the thing in that case (and you'd have to remember not ever to use any of the buffered routines)
The important thing is to try it, of course, especially where perl performance is concerned. Remember that perl is interpreted (it compiles to a byte-code at runtime), but the internal functions are compiled, and are always faster.
perl /home/ahunter/grob.pl < xlib.ps 39.04s user 0.24s system 95% cpu 41.126 total
Well, a 3x speed-up over the original isn't really all that bad, I suppose.