473,387 Members | 1,291 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Help with some terminology

(1) Can anyone please tell me the exact meaning of primitive types in
the MSIL context.

(2) Also what is the meaning of the world inline?

(3) What is the meaning of the statement: "You should bear in mind,
however, that decimal is not implemented under the hood as a primitive
type, so using decimal will have a performance impact on your
calculations." ?

(4) What makes value types work faster than reference types. The only
speed difference is during object creation right? Value types on stack
are created faster than creating a reference type on the heap. After
this, what makes one faster than the other?

Thanks

Joel

Jan 28 '07 #1
5 1416


"Joel" <jo*******@gmail.comwrote in message
news:11*********************@m58g2000cwm.googlegro ups.com...
(1) Can anyone please tell me the exact meaning of primitive types in
the MSIL context.

(2) Also what is the meaning of the world inline?

(3) What is the meaning of the statement: "You should bear in mind,
however, that decimal is not implemented under the hood as a primitive
type, so using decimal will have a performance impact on your
calculations." ?

(4) What makes value types work faster than reference types. The only
speed difference is during object creation right? Value types on stack
are created faster than creating a reference type on the heap. After
this, what makes one faster than the other?
Homework?

David

Jan 28 '07 #2
Homework?

I'm afraid I've done my homework David. I've looked for answers to the
above questions but still don't feel very good about them so thought
of asking.

Please excuse me. :|

Joel

Jan 28 '07 #3


"Joel" <jo*******@gmail.comwrote in message
news:11**********************@p10g2000cwp.googlegr oups.com...
>Homework?

I'm afraid I've done my homework David. I've looked for answers to the
above questions but still don't feel very good about them so thought
of asking.

Please excuse me. :|

Joel
Ok,

Here's some pointers
(1) Can anyone please tell me the exact meaning of primitive types in
the MSIL context.
AFAIK "primitive types" has no exact technical meaning in the MSIL context.
In general "primitive types" are used to refer either to the built-in value
types, or to the types which represent processor primitives in the platform.
These always include things like 32bit integers, floats, booleans, etc.
(2) Also what is the meaning of the world inline?
In C++ declaring and defining a function as 'inline' instructs the compiler
to expand function calls to this function and place a copy of the functions
body in place of the method call. Essentially 'inline' is a copilier
optimization exposed in the programming language. This is consistent with
C++'s design philosophy, but not with C#. In C# such optimizations are left
up to the discresion of the Just-in-Time compiler.

(3) What is the meaning of the statement: "You should bear in mind,
however, that decimal is not implemented under the hood as a primitive
type, so using decimal will have a performance impact on your
calculations." ?
Adding two int's or two float's takes only a single processor instruction.
Adding two decimals might take thousands. So for scientific and technical
applications where number-crunching speed matters, you should take this into
account. For general computation, the performance difference is unlikely to
be noticeable.
>
(4) What makes value types work faster than reference types. The only
speed difference is during object creation right? Value types on stack
are created faster than creating a reference type on the heap. After
this, what makes one faster than the other?
In .NET reference type allocation is very fast, and so allocation speed is
the least of the performance advantages for value types. The performance
benefits of value types are:

Locality
There is a bottleneck between the processor and main memory, and code
operating on data that is bunched locally together is more efficient. Value
types allocated on the stack promote locality in your code by helping to
concentrate the memory footprint of your program on the top part of the
stack, rather than having data scattered around the managed heap. Although
heap allocation does have some locality in .NET due to the fact that managed
heap allocations always occur at the 'end' of the heap, and large object
allocations are segregated to another heap.

Copy-by-value Semantics
For small types, passing the type value is minimally more expensive than
passing a pointer, and you save both the operation and the memory read of
dereferencing the pointer when accessing the value.

Deallocation Cost
This is the big one. Value types on the stack are deallocated by simply
moving back the stack pointer at the end of the scope. Reference types are
garbage collected.

Allocation Cost
Heap allocation is fast, but during a heap allocation you might trigger
a garbage collection and have to wait until after the collection is done for
the allocation to succeed.
However, the sum total of all these performance differences doesn't amount
to much for most programs. In general you should use the types and
techniques optimize the simplicity and understandability of the program, and
only optimize for performance when you are dealing with some special
performance requirement.

David

Jan 28 '07 #4
Here's some pointers

Thanks a lot David. :-)

Joel

Jan 28 '07 #5
Here's some pointers

Thanks a lot David. :-)

Joel

Jan 28 '07 #6

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

Similar topics

20
by: drs | last post by:
Hi, I am trying to find all lists of length x with elements a, b, and c. To this end, I have created the class below, but it is not quite working and I am having trouble figuring out what to...
4
by: Dave | last post by:
Hello all, Consider this template: template <typename T> void foo(T bar) {...} Here are three ways to instantiate this: 1.
38
by: lawrence | last post by:
I'm just now trying to give my site a character encoding of UTF-8. The site has been built in a hodge-podge way over the last 6 years. The validator tells me I've lots of characters that don't...
8
by: Andrew McNab | last post by:
Hi folks, I have a problem with an MS Access SQL query which is being used in an Access Report, and am wondering if anyone can help. Basically, my query (shown below) gets some records from a...
20
by: Jack Schitt | last post by:
I thought I was starting to get a handle on Access, until I tried doing something useful...now I'm stuck. I have a DB with two tables - to keep it simple I'll say that one is an Employee File...
6
by: Don Sealer | last post by:
I've written this expression for a DLookup function. It works almost alright. What I'm trying to do is type in a description and the ID field (number) populates automatically. It works almost as...
193
by: Michael B. | last post by:
I was just thinking about this, specifically wondering if there's any features that the C specification currently lacks, and which may be included in some future standardization. Of course, I...
2
by: bryan | last post by:
I have a situation that's pretty delicate that I need some help on. I've been stumped for awhile I just need some advice on the best possible solution. The problem: I have a site I'm making...
9
by: Chrissy | last post by:
I took a C# class as an elective and received an incomplete in it and am desparate for help. I have two assignments left (arrays and inheritance) and would gladly pay anyone that can assist me with...
1
by: Troy Bull | last post by:
Greetings I am trying to use a singleton to hold a group of forms. I have a MDIMaster form. I have a class called Forms; Forms is a singleton. I want to do something like the following. In...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...

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.