Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / CLR / December 2003

Tip: Looking for answers? Try searching our database.

Valuetypes vs. Reference Types

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Klaus L?ffelmann - 26 Nov 2003 11:47 GMT
Hello,

since value types don't have to be dereferenced, they're supposed to be
faster than reference types (exceptions aside). To prove this, I developed a
testprg in VB and to my surprise and the opposite proofed! I looked at the
IML-Code and noticed, that the VB-compiler "invented" an other (third) value
type object, even if I only used two value types in the sample. I then did
the same in C#, and the IML-code was perfect.

So my questions are:

a) Does anybody know about a "weird" behaviour with value types of the
vb.compiler?
b) (Has nothing to do with this, just another question): Can I assume that a
value type is usually to be accessed quicker, since the probability that it
is already hosted in a processor cache is higher than with referece types
(at least if a program cosumes large amount of space)?

If you want to have the samples for testing, simply mail me to
testaccount01 at loeffelmann dot de

Klaus
Mattias Sj?gren - 26 Nov 2003 11:55 GMT
Klaus,

>a) Does anybody know about a "weird" behaviour with value types of the
>vb.compiler?

I'm not sure what the weird behavior is that you're describing. It
would be a lot easier to comment of you posted relevant parts of the
code here. Did you do an optimized build?

>b) (Has nothing to do with this, just another question): Can I assume that a
>value type is usually to be accessed quicker, since the probability that it
>is already hosted in a processor cache is higher than with referece types
>(at least if a program cosumes large amount of space)?

You may want to post that to the .performance newsgroup.

Mattias

Signature

Mattias Sjögren [MVP]  mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.

Matthew W. Jackson - 08 Dec 2003 05:34 GMT
I'm guessing that it has something to do with VB's loose type-safety.

Try adding "Option Strict" and compile the code again.  I know that VB
without Option Strict can write refleciton-code to do late-binding, so the
results you are seeing may be as a result of that feature.

It has been my experience that VB with Option Strict should produce similar
IL code to C#, but I've never investigated the matter myself.

--Matthew W. Jackson

> Hello,
>
[quoted text clipped - 18 lines]
>
> Klaus

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.