in reply to Re: How To Do This Better?
in thread How To Do This Better?
You probably meant to say:
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.
-- Andrew
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.while(!eof(FILE)) { my $c = getc(FILE); $count{lc($c)}++ if $c=~/[a-zA-Z]/; }
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.
-- Andrew
|
---|
Replies are listed 'Best First'. | |
---|---|
RE: RE: Re: How To Do This Better?
by NoTwoGroo (Initiate) on Apr 15, 2000 at 01:12 UTC |
In Section
Seekers of Perl Wisdom