473,563 Members | 2,867 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

out method and method with return value

In performance wise which is more costly to use when there one value to return?
Is it the out method parameter or the method that has a return value?

Dec 19 '07 #1
10 1342
"lianqtlit" <li*******@disc ussions.microso ft.comwrote in message
news:83******** *************** ***********@mic rosoft.com...
In performance wise which is more costly to use when there one value to
return?
Is it the out method parameter or the method that has a return value?
Return value I presume. In most languages the return value is returned in a
register whereas a parameter is placed on the stack.
>

Dec 19 '07 #2
lianqtlit wrote:
In performance wise which is more costly to use when there one value to return?
Is it the out method parameter or the method that has a return value?
It is extremely unlikely that the difference will have any impact on
your overall performance.

Focus on readable code instead of "nanosecond s performance tuning".

Arne
Dec 19 '07 #3
Michael C wrote:
"lianqtlit" <li*******@disc ussions.microso ft.comwrote in message
news:83******** *************** ***********@mic rosoft.com...
>In performance wise which is more costly to use when there one value to
return?
Is it the out method parameter or the method that has a return value?

Return value I presume. In most languages the return value is returned in a
register whereas a parameter is placed on the stack.
Did you read it as "more efficient" or do you think register is slower
than stack ?

Arne
Dec 19 '07 #4
"Arne Vajhøj" <ar**@vajhoej.d kwrote in message
news:47******** *************** @news.sunsite.d k...
Did you read it as "more efficient" or do you think register is slower
than stack ?
Sorry, I misread what the OP said. I think the register will be faster and
more efficient.

Michael
Dec 19 '07 #5
"lianqtlit" <li*******@disc ussions.microso ft.comwrote in message
news:83******** *************** ***********@mic rosoft.com...
In performance wise which is more costly to use when there one value to
return?
Is it the out method parameter or the method that has a return value?

You should definitely not care about this, chances are that the method is
inlined, and if not, the (single) argument is passed in a register too.
Managed code uses the "CLR calling" convention when running on X86, that is,
it passes the first two arguments in a register. The 'this' pointer is
passed in 'ecx' while the "first" argument is passed in 'esi'. More, when
running on X64 in 64-bit mode, the first four arguments are passed in a
register, so here you have even less reasons to care about argument passing
efficiency.

Willy.
Dec 19 '07 #6

"Willy Denoyette [MVP]" <wi************ *@telenet.bewro te in message
news:e3******** ******@TK2MSFTN GP05.phx.gbl...
"lianqtlit" <li*******@disc ussions.microso ft.comwrote in message
news:83******** *************** ***********@mic rosoft.com...
>In performance wise which is more costly to use when there one value to
return?
Is it the out method parameter or the method that has a return value?


You should definitely not care about this, chances are that the method is
inlined, and if not, the (single) argument is passed in a register too.
out arguments have to be passed by address... unless inlined

Just make sure the function is inlined.

As a side note, the out parameter can use type inference, the return type
can't (except for op_Implicit and op_Explicit).
Dec 19 '07 #7
"Ben Voigt [C++ MVP]" <rb*@nospam.nos pamwrote in message
news:uW******** ******@TK2MSFTN GP04.phx.gbl...
>
"Willy Denoyette [MVP]" <wi************ *@telenet.bewro te in message
news:e3******** ******@TK2MSFTN GP05.phx.gbl...
>"lianqtlit" <li*******@disc ussions.microso ft.comwrote in message
news:83******* *************** ************@mi crosoft.com...
>>In performance wise which is more costly to use when there one value to
return?
Is it the out method parameter or the method that has a return value?


You should definitely not care about this, chances are that the method is
inlined, and if not, the (single) argument is passed in a register too.

out arguments have to be passed by address... unless inlined
Yep, sorry for the confusion, what I meant was that a single argument is
passed in a register, not on the stack.
What is returned is also placed in a register (by convention eax on X86), be
it an address or a value
Just make sure the function is inlined.
You don't have control over this, it's the JIT who decides what will be
inlined.
As a side note, the out parameter can use type inference, the return type
can't (except for op_Implicit and op_Explicit).
Agreed.

Willy.


Dec 20 '07 #8
"Willy Denoyette [MVP]" <wi************ *@telenet.bewro te in message
news:e3******** ******@TK2MSFTN GP05.phx.gbl...
You should definitely not care about this, chances are
Chances are much improved (to certainty) that the return value will be in a
register if it is not a parameter. :-)

Michael
Dec 20 '07 #9
"Michael C" <mi**@nospam.co mwrote in message
news:u$******** ******@TK2MSFTN GP04.phx.gbl...
"Willy Denoyette [MVP]" <wi************ *@telenet.bewro te in message
news:e3******** ******@TK2MSFTN GP05.phx.gbl...
>You should definitely not care about this, chances are

Chances are much improved (to certainty) that the return value will be in
a register if it is not a parameter. :-)

Michael
Sure, on X86 return values can even occupy two registers, a long or a double
return value for instance are returned in 'eax' and 'edx'. Note that I'm
absolutely not promoting passing ByRef values, this is a matter of the
semantic requirements, all I'm trying to say is that the JIT32 uses a
calling sequence which allows you to pass single argument (plus the this
pointer) in a register.

Willy.


Dec 20 '07 #10

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

Similar topics

6
2757
by: max reason | last post by:
A method in one of my classes needs to call one of 256 other methods in the same class based on an unsigned 8-bit value (0x00 to 0xFF). How is this done? Everything I try generates errors. Something this basic can't be so difficult (or impossible) - can it? Thanks. The following roughly shows what I want: class simple { public:
1
1275
by: =steFF= | last post by:
Hi, I am trying to print the values I have in a vector and my compiler says: error C2227: left of '->printLn' must point to class/struct/union on this instruction: m_data->printLn(); (in my file pile.h) Can someone tell why it says that? Also, I don't understand why I am not allowed to put const on this method: void printLn(); when I...
12
6719
by: Rubbrecht Philippe | last post by:
Hi there, According to documentation I read the ArrayList.IndexOf method uses the Object.Equals method to loop through the items in its list and locate the first index of an item that returns True. Therefore, overriding the Equals method in the class definition of the items I put in the ArrayList should make the IndexOf method use my...
18
4721
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 class where only the "searched" property has a value. I expected to get the index into the arraylist where I could then get the entire class...
1
2341
by: tony | last post by:
Hello!! Hello Victor! I use a product called flygrid to create grid tables. In many of my forms I create such grid tables. Some columns in these grid tables is of type drop down list where I can select a value from the list. Below I have some code which exist in a file named StringClass.cs
3
14993
by: BombDrop | last post by:
Can any one help I have a method that will return a List to be bound as a datasource to a combobox see code for population below. I get the following error when i try to compile Error 29 Cannot implicitly convert type 'System.Collections.Generic.List<Prsym.ComboPopulation.ComboInfo>' to 'System.Collections.Generic.List<T> '
0
3851
by: martinmercy2001 | last post by:
Could any body help me with creating a ring buffer class using a string. use memory circular buffer not an IO buffer. just read, write and seek method. Read method should take anumber and return the string. write method should take a string. seek should take a number and return nuthing. use three member variables a buffer itself as a string,...
5
4593
by: Anders Borum | last post by:
Hi! While implementing a property manager (that supports key / value pairs), I was wondering how to constrain T to a struct or string type. Basically, I guess what I'm looking for is the common denominator for structs and strings and while looking through the SDK I only noticed the IEquatable<T> interface. So I implemented the class with...
1
6480
by: madman228 | last post by:
Hi guys I have run in to a littl bit of trouble. I am writing a class called polynomial in which i need a derivative method I have everything, just dont know how to start the derivative method. Any help will be appriciated here is the code: import java.io.*; import java.util.Scanner; public class Polynomial extends UnorderedArrayList {...
0
7665
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
1
7642
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6255
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5484
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5213
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3643
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1200
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
924
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.