how to be faster than perl?
Frits van Bommel
fvbommel at REMwOVExCAPSs.nl
Tue Jan 30 07:03:36 PST 2007
Boris Bukowski wrote:
> buko01 at dizit:~/d$ time ./lineio.pl access.log
> 1087
>
> real 0m0.105s
> user 0m0.092s
> sys 0m0.012s
> buko01 at dizit:~/d$ time ./lineio2 access.log
> 1087
>
> real 0m1.547s
> user 0m1.528s
> sys 0m0.020s
>
> still 15 times slower :-(
> Perl strings/IO must be somehow black magic.
> Looks like I have to write my own lineReader.
Some obvious questions:
Did you use -O -inline? If not, try those. I don't think they'll make
much difference.
Do you actually search for "horizontal" (or a similar fixed string) ? To
search for a non-regex string, std.string.find will likely be faster.
Other than that, I'm out of ideas.
IIRC Perl compiles regexes inline, presumably optimizing them along with
the rest of the code, so that might explain why it's faster. This sort
of stuff is what Perl was designed for...
More information about the Digitalmars-d-learn
mailing list