Why is D slower than LuaJIT?

Iain Buclaw ibuclaw at ubuntu.com
Wed Dec 22 14:58:34 PST 2010


== Quote from Andreas Mayer (spam at bacon.eggs)'s article
> To see what performance advantage D would give me over using a scripting
language, I made a small benchmark. It consists of this code:

One corner case doesn't amount to an end-all be-all proof to anything.

> >    auto L = iota(0.0, 10000000.0);
> >    auto L2 = map!"a / 2"(L);
> >    auto L3 = map!"a + 2"(L2);
> >    auto V = reduce!"a + b"(L3);
> It runs in 281 ms on my computer.
> The same code in Lua (using LuaJIT) runs in 23 ms.
> That's about 10 times faster. I would have expected D to be faster. Did I do
something wrong?
> The first Lua version uses a simplified design. I thought maybe that is unfair
to ranges, which are more complicated. You could argue ranges have more features
and do more work. To make it fair, I made a second Lua version of the above
benchmark that emulates ranges. It is still 29 ms fast.

As has been already echoed, the lack of inlining algorithmic functions may be one
reason for the added cost to runtime. Another may be simply that there is a lot
more going on behind the scenes than what you give credit for in D.

Regards :~)


More information about the Digitalmars-d mailing list