C faults, etc
Lutger
lutger.blijdestijn at gmail.com
Mon Jul 20 10:40:09 PDT 2009
bearophile wrote:
> Daniel Keep:
>>Why on earth should the D compiler special-case a function that's not even
>>supposed to be used?!<
>
> What's the purpose of being able to use the C std lib in D programs if
> then such functions aren't supposed to be used?
>
>
>> Actually, let's check... (Goes off to test.)<
>
> This is a first little test, with DMD V.2.031, on Windows, Phobos2:
>
> import std.stdio: printf;
> void main() {
> const int N = 2_000_000;
> for (int i; i < N; i++)
> printf("test %d\n", i);
> }
>
>
> A second version that uses writefln:
>
> import std.stdio: writefln;
> void main() {
> const int N = 2_000_000;
> for (int i; i < N; i++)
> writefln("test %d", i);
> }
>
> I have redirected their output to a file (26.2 MB file).
> The timings are: 1.16 seconds for the version with printf, and 14.93
> seconds for the version with writefln.
>
writefln does a flush where writef doesn't. On my system (fedora 11) all
timings are nearly the same however, while writef is actually a bit faster
than printf. What OS are you on?
More information about the Digitalmars-d
mailing list