cost of calling class function

Seb via Digitalmars-d digitalmars-d at puremagic.com
Wed Feb 22 17:48:40 PST 2017


On Wednesday, 22 February 2017 at 23:49:43 UTC, DuĊĦan Pavkov 
wrote:
> Hello,
>
> I have tried to measure how much would some simple task be 
> faster in D than in C#. I ported some simple code from C# to D 
> 1:1 almost without changes and C# code was faster. After 
> eliminating causes one by one I have an example which shows 
> where the problem is. If the function is outside of class code 
> runs much faster. I'm obviously doing something wrong and would 
> appreciate any help with this.

I think I can provide a couple of pointers for one reason. The 
function isn't final and virtual calls are inefficient:

https://dlang.org/spec/function.html#virtual-functions
http://forum.dlang.org/post/mailman.840.1332033836.4860.digitalmars-d@puremagic.com
https://issues.dlang.org/show_bug.cgi?id=11616
http://wiki.dlang.org/DIP51

AFAICT though it was approved, the switch to final by default has 
never happened.


More information about the Digitalmars-d mailing list