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?<br>
<br><br><div class="gmail_quote">On Sun, Aug 8, 2010 at 11:54 PM, bearophile <span dir="ltr"><<a href="mailto:bearophileHUGS@lycos.com">bearophileHUGS@lycos.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Andrej Mitrovic:<br>
<div class="im"><br>
> Andrei used to!string() in an early example in TDPL for some line-by-line<br>
> processing. I'm not sure of the advantages/disadvantages of to!type vs .dup.<br>
<br>
</div>I have modified the code:<br>
<div class="im"><br>
import std.stdio: File, writeln;<br>
</div>import std.conv: to;<br>
<div class="im"><br>
int process(string fileName) {<br>
int total = 0;<br>
<br>
auto file = File(fileName);<br>
foreach (rawLine; file.byLine()) {<br>
</div> string line = to!string(rawLine);<br>
<div class="im"> total += line.length;<br>
}<br>
file.close();<br>
<br>
return total;<br>
}<br>
<br>
void main(string[] args) {<br>
if (args.length == 2)<br>
writeln("Total: ", process(args[1]));<br>
}<br>
<br>
<br>
</div>The run time is 1.29 seconds, showing this is equivalent to the idup.<br>
<br>
Bye,<br>
<font color="#888888">bearophile<br>
</font></blockquote></div><br>