Performance of method calls
Sean Kelly
sean at f4.ca
Thu Nov 30 06:25:05 PST 2006
Daniel Keep wrote:
>
> I just recompiled and re-ran with some different flags. The results
> are... interesting.
>
> (Numbers are #1/#2 and #3/#2)
>
> -O: 1.39892 and 3.61384
> -O -release: 1.00703 and 1.0163
> -O -inline: 1.89054 and 13.4001
> -O -release -inline: 1.8257 and 1.00007
>
> Now I've got *no* idea what to think :P
For what it's worth, I've noticed that inlining of struct methods is
inconsistent (the last case). I ran some tests a while back and in some
cases simply changing the method to/from a static method was enough to
affect whether it was inlined. And I think how the method is used is a
factor as well. I am using structs with opCall as default comparators
in my algorithm code because they have the potential to be inlined,
while delegates currently do not, but even:
struct IsEqual(T) { bool opCall(T a, T b) { return a == b; } }
only inlines in some of the algorithms. And this may be true of
inlining in general--I simply haven't looked into the problem enough.
Sean
More information about the Digitalmars-d
mailing list