Groups | Blog | Home
all groups > dotnet performance > november 2003 >

dotnet performance : Performance of properties vs method calls


François_Lemaire
11/20/2003 10:34:10 AM
Do you know ildasm in the .NET framework SDK? It's a tool=20
that lets you see MSIL, the intermediate language used by=20
the CLR. If you look at your MSIL for an accessor, you'll=20
see that it is transformed into a method=20
(get_MyAccessorName, set_MyAccessorName). You could also=20
try to name a method get_MyAccessorName; the compiler will=20
pop an error (I just did :)).

So my guess is that there's no point in your question=20
because your accessor is indeed a method, so there's no=20
performance difference and both are inlined. But maybe a=20
more clever guy will prove me that I'm wrong ;)

Peace

Fran=E7ois Lemaire

[quoted text, click to view]
discussion NO[at]SPAM discussion.microsoft.com
11/20/2003 2:34:33 PM
Hi,

Since small method calls are inlined when the IL size is 32 or less.

Take for example..

// Method (inlined)
public bool getVal()
{
return someVal;
}

// propget
public bool Val
{
ge { return someVal; }
}


Which is faster? If the method is unoptimised its therefore poped onto
the stack so obviously slower than the propget.

When it is inline its not pushed onto the stack, but it is JITted to be
inline wheras a prop is what?

Is there a difference or is it smart enough? Does the method take ahit on
the initial JIT and the propget doesnt?

Thanks

AddThis Social Bookmark Button