stdio line-streaming revisited
torhu
fake at address.dude
Thu Mar 29 03:20:54 PDT 2007
Andrei Alexandrescu (See Website For Email) wrote:
> On my machine, Tango does 4.3 seconds and the following phobos program
> (with Walter's readln) does 5.4 seconds:
>
> #!/usr/bin/env rundmd
> import std.stdio;
>
> void main() {
> char[] line;
> while (readln(line)) {
> write(line);
> }
> }
>
> where write is a function that isn't yet in phobos, of the following
> implementation:
>
> size_t write(char[] s) {
> return fwrite(s.ptr, 1, s.length, stdout);
> }
On my Windows machine, using fwrite like that makes phobos twice as fast
as the version using fputs. But tango is still twice as fast as that.
More information about the Digitalmars-d
mailing list