tolf and detab
Andrej Mitrovic
andrej.mitrovich at gmail.com
Sun Aug 8 15:24:31 PDT 2010
What are you using to time the app? I'm using timeit (from the Windows
Server 2003 Resource Kit). I'm getting similar results to yours. Btw, how do
you use a warm disk cache? Is there a setting somewhere for that?
On Sun, Aug 8, 2010 at 11:54 PM, bearophile <bearophileHUGS at lycos.com>wrote:
> Andrej Mitrovic:
>
> > Andrei used to!string() in an early example in TDPL for some line-by-line
> > processing. I'm not sure of the advantages/disadvantages of to!type vs
> .dup.
>
> I have modified the code:
>
> import std.stdio: File, writeln;
> import std.conv: to;
>
> int process(string fileName) {
> int total = 0;
>
> auto file = File(fileName);
> foreach (rawLine; file.byLine()) {
> string line = to!string(rawLine);
> total += line.length;
> }
> file.close();
>
> return total;
> }
>
> void main(string[] args) {
> if (args.length == 2)
> writeln("Total: ", process(args[1]));
> }
>
>
> The run time is 1.29 seconds, showing this is equivalent to the idup.
>
> Bye,
> bearophile
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20100809/fce0524f/attachment.html>
More information about the Digitalmars-d
mailing list