Naive node.js faster than naive LDC2?

James Lu jamtlu at gmail.com
Sat Aug 22 00:21:50 UTC 2020


On Friday, 21 August 2020 at 23:49:44 UTC, H. S. Teoh wrote:
> On Fri, Aug 21, 2020 at 11:22:27PM +0000, James Lu via 
> Digitalmars-d wrote: [...]
>> Bonus: Direct translation of Dlang to Node.js, Node.js faster 
>> https://gist.github.com/CrazyPython/8bafd16837ec8ad4c5a638b9d305fc96
>> 
>> Dlang: 4076 3622 2934 (3544 average)
>> Node.js: 2624 2334 2316 (2424 average)
>> 
>> LDC2 is 46% slower!
>
> Using a class for Complex (and a non-final one at that!!) 
> introduces tons of allocation overhead per iteration, plus 
> virtual function call overhead.  You should be using a struct 
> instead.  I betcha this one change will make a big difference 
> in performance.
>
> Also, what's the command you're using to compile the program?  
> If you're doing performance comparison, you should specify -O2 
> or -O3.
>
>
> T

I showed with and without class. V8's analyzer might be superior 
to LDC's in removing the allocation overhead. I used the same 
compilation flags as the original:

ldc2 -release -mcpu=native -O3 -ffast-math --fp-contract=fast


More information about the Digitalmars-d mailing list