Why Java (server VM) is faster than D?
Steven Schveighoffer via Digitalmars-d
digitalmars-d at puremagic.com
Mon Aug 3 09:41:42 PDT 2015
On 8/3/15 12:31 PM, Dmitry Olshansky wrote:
> On 03-Aug-2015 19:27, aki wrote:
>> When I was trying to port some Java program to D,
>> I noticed Java is faster than D.
>> I made a simple bench mark test as follows.
>> Then, I was shocked with the result.
>> test results on Win8 64bit (smaller is better)
>> Java(1.8.0,64bit,server): 0.677
>> C++(MS vs2013): 2.141
>> C#(MS vs2013): 2.220
>> D(DMD 2.067.1): 2.448
>> D(GDC 4.9.2/2.066): 2.481
>> Java(1.8.0,32bit,client): 3.060
>> Does anyone know the magic of Java?
>> Thanks, Aki.
> Devirtualization? HotSpot is fairly aggressive in that regard.
Yeah, I think that's it. virtual calls cannot be inlined by the D
compiler, but could be inlined by hotspot. You can fix this by making
the derived class final, or marking the method final, and always using a
reference to the derived type. If you need virtualization still, you
will have to deal with lower performance.
More information about the Digitalmars-d