472,965 Members | 2,053 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,965 software developers and data experts.

Method vs Property performance

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
Nov 15 '05 #1
2 4752
I would think it is smart enough. The reason being is that properties
are really methods (you will notice get_Property and set_Property methods on
your class when you look at the IL), and I would imagine that these are
subject to the same optimizations.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

<di********@discussion.microsoft.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
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

Nov 15 '05 #2
That's my guess as well.

Why not just write a simple test program? Either run and time it, or look
at the IL and see if there are any differences.

Remember though, the optimizations that the compiler does will change
(hopefully improve) with each release.

Eric

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:e3**************@TK2MSFTNGP11.phx.gbl...
I would think it is smart enough. The reason being is that properties
are really methods (you will notice get_Property and set_Property methods on your class when you look at the IL), and I would imagine that these are
subject to the same optimizations.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

<di********@discussion.microsoft.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
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



Nov 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: william | last post by:
Hi, I'm playing windows service using vb.net. I added a performance counter to my windows service, but I couldn't set MachineName property of the performance counter to blank. After I set it to...
5
by: Vicky via DotNetMonster.com | last post by:
Hi, I need help with "An object reference is required for the nonstatic field, method, or property 'dataReader.Class1.data'" Before I put folowing variable in class level, it works fine....
5
by: fred | last post by:
With a Class is there any difference between a readonly property and function besides having to use Get/End Get. Are there any performance/resource advantages for either. Thanks Fred
18
by: JohnR | last post by:
From reading the documentation, this should be a relatively easy thing. I have an arraylist of custom class instances which I want to search with an"indexof" where I'm passing an instance if the...
4
by: kplkumar | last post by:
This is what my supervisor is looking for. We want runtime debugging/trace logging. In other words, we want to log every method that was executed, perhaps the variables in it as well - everytime...
2
by: netasp | last post by:
hi all, I need your help with the following scenario: I am using VS 2005 and SQL server DB, my form has 3 textboxes txtTotalAmount, txtAmountEntered, txtAmountBalance. If txtTotalAmount is...
3
by: jbeteta | last post by:
Hello, I have a problem declaring variables. I need to create an object oRpte as ReportClass on WebForm1.aspx and be able to use its value on WebForm2.aspx. For declaring the property oRpte()...
19
by: zzw8206262001 | last post by:
Hi,I find a way to make javescript more like c++ or pyhon There is the sample code: function Father(self) //every contructor may have "self" argument { self=self?self:this; ...
15
by: caca | last post by:
Hello, This is a question for the best method (in terms of performance only) to choose a random element from a list among those that satisfy a certain property. This is the setting: I need to...
7
by: Brian | last post by:
I am looking for a way to store maybe in an array or dictionary... two fields.... first field would be a string... second would be a date... for example.. if i called up myinfo(0) it would show...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.