HighTechTalks DotNet Forums  

cast type check performance

Dotnet Framework (Performance) microsoft.public.dotnet.framework.performance


Discuss cast type check performance in the Dotnet Framework (Performance) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #11  
Old   
Jon Skeet [C# MVP]
 
Posts: n/a

Default Re: cast type check performance - 04-18-2006 , 06:27 PM






Etienne <etienne.lebeau (AT) matrox (DOT) com> wrote:
Quote:
I've tried with your test harness with my class ComparableByteArray and
it it gives me the same results. Remming out the lines which pass null
does improve the method who avoid "is" but did not perform better than
the first.
Hmm. Interesting. It's worth noting here that *most* of the time is
actually spent in Equals itself. The difference in performance between
the two (at least on my box) is very small compared with the total
time. I would be surprised to see a real-life app where it actually
made a significant difference.

However, I'm still surprised to see "is then as" beating "as then
nullity" in the first place. Hmm.

--
Jon Skeet - <skeet (AT) pobox (DOT) com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too


Reply With Quote
  #12  
Old   
Etienne
 
Posts: n/a

Default Re: cast type check performance - 04-18-2006 , 08:47 PM






Hi,
I finally found why I was having those strange results. I had to do
with the fact that the method # 2 is using the != operator overload
which is implemented using the Equals()...
Casting to (object) before the nullity check give good results. Thank
you all for this discussion, it was quite interesting.
Best Regards,

Etienne Lebeau, ing. jr.
Software Designer
Matrox Graphics


Reply With Quote
  #13  
Old   
Jon Skeet [C# MVP]
 
Posts: n/a

Default Re: cast type check performance - 04-19-2006 , 01:31 AM



Etienne <etienne.lebeau (AT) matrox (DOT) com> wrote:
Quote:
I finally found why I was having those strange results. I had to do
with the fact that the method # 2 is using the != operator overload
which is implemented using the Equals()...
Oh of course - doh! Sorry for not spotting that before.

--
Jon Skeet - <skeet (AT) pobox (DOT) com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too


Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.