bearophile wrote:
Adam Ruppe:
D2's (relative) slowness I've tracked down to import std.stdio; - it
instantiates a bunch of templates just on import. We should be able to
fix this with a little work, and put D even further ahead of the
competition.
I have done two little benchmarks, using dmd 2.047, compiling just with "dmd
test.d":
import std.c.stdio: printf;
void main() {
printf("%d\n", 10);
}
import std.stdio: writeln;
void main() {
writeln(10);
}
The program with printf compiles in 0.05 seconds, and the binary is 101_404
bytes, while the program with writeln compiles in about 0.30 seconds and
produces a binary of 235_036 bytes, the asm shows tons of templates and
functions.
Bye,
bearophile
I've improved on this a bit, and further improvements are easy. If you
print strings, write and writeln simply forward to printf. Similar
special casing can be done for simple and frequent cases.
BTW, speed of compilation of very short programs is not very relevant as
long as it's reasonably good.
Andrei