how to be faster than perl?

Unknown W. Brackets unknown at simplemachines.org
Tue Jan 30 23:46:23 PST 2007


I'm a bit tired, but does BufferedFile's opApply use a fixed buffer?  I 
doubt it does.  In this case, the foreach method is going to be a lot 
slower than reading lines into a buffer.

Check on the other methods of BufferedFile.

Sorry, I'd give a code example but I'm just doing a drive by.

-[Unknown]


> Hi,
> 
> currently I am testing D for log processing.
> My perl script is more than ten times faster than my D Prog.
> How can I get Lines faster from a File?
> 
> Boris 
> 
> ---snip---
> private import std.stream;
> private import std.stdio;
> private import std.string;
> 
> void main (char[][] args) {
>         int c;
>         Stream file = new BufferedFile(args[1]);
>         foreach(ulong n, char[] line; file) {
>                 if(std.regexp.find(line, "horizontal") > -1){
>                         c++;
>                 }
>         }
> 
>         writefln("%d", c);
> 
> }
> ---snip---
> 
> #!/usr/bin/perl
> 
> while($line=<>) {
>         if ($line=~/horizontal/) {
>                 $c++;
>         }
> }
> 
> print "$c\n";
> 
> ---snip---
> 


More information about the Digitalmars-d-learn mailing list