how to be faster than perl?
Boris Bukowski
boris.bukowski at lycos-europe.com
Tue Jan 30 06:02:22 PST 2007
> // (untested code)
> auto re = new RegExp("horizontal");
> foreach (ulong n, char[] line; file) {
> if (re.find(line) > -1) {
> // ...
> -----
> as the start of your foreach loop.
> That should be faster.
>
> I don't know how fast it'll be compared to Perl; I don't know anything
> about the relative performance of D vs. Perl regexes. (In fact, I hardly
> ever use regexes, and have never used Perl)
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.
Boris
More information about the Digitalmars-d-learn
mailing list