With the recent changes to Nullables in v2.0, I wanted to go back to some old tests that had not been very satisfying when I ran them over a year ago.
One was comparing the speed of using a Nullable<T> and testing to see if has a value or not with HasValue to the speed of a just checking for either a null or default value in a system.type.
Here were my results from doing this in July 2004
You will see that a Nullable<Int32> test was much slower than Int32>0 and a Nullable<object> test was slower than object = = null (or IsNull in VB).
Now with the August 05 CTP, things have sped up. One thing to note is that you can't use Nullable<T> with already nullable values as you could before. So now I am only testing against int.
Using the same 500,000 interations with a Nullable<int>, although the gap is shrinking, is still somewhat slower. Three tests gave these results
Still, I much prefer Nullable<T> over the other test. What do you test for with dates?
Remember Me
See my speaking schedule for more events
User Group Leader
Hosted by:
Powered by: newtelligence dasBlog 2.0.7226.0
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.
© Copyright 2008, Julie Lerman
E-mail