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 <bearophileh...@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 >