Real World

by Nick Saturday, May 12, 2007 10:56 AM

This is interesting.  I'm currently reading a Self-Paced Training Kit book for an exam towards my MCPD.  It's talking about different features in .NET 2.0 (which seems kind of boring since I really already know all of this).  However, what is good so far about this book are the occasional interludes of "Real World" information thrown in by the authors that break from the normal "Oo Ra Ra, Go Microsoft" information.  One of them is talking about Generics (a feature that I love) which shocked me:

I haven't been able to reproduce the performance benefits of generics; however, according to Microsoft, generics are faster than using casting.  In practice, casting proves to be several times faster than using a generic.  However, you probably won't notice performance differences in your applications.  (My tests over 100,000 iterations took only a few seconds.)  So you should still use generics because they are type-safe.

Huh?!  Granted, the type safety aspect is a huge benefit.  However, I can't tell you how many times I've heard from Microsoft people about the huge performance benefits.

To be honest, I always suspected a problem in that respect, but I always thought it was me.  I had written a .NET 1.1 library a while ago that implemented different types of Binary Search Trees and a Skip List.  When .NET 2.0 came out, I decided to make a 2.0 version using Generics as an exercise to learn the new feature.  When I did some timing comparisons, I found that it was either a little slower, or largely the same depending on the test.  I always figured it was something in my implementation, or my timing code.  Maybe it wasn't me after all.

Comments are closed

About Me

Nick Schweitzer Nick Schweitzer
Wauwatosa, WI

Contact Me
I'm a Software Consultant in the Milwaukee area. Among various geeky pursuits, I'm also an amateur triathlete, and enjoy rock climbing. I also like to think I'm a political pundit. ... Full Bio

Community Involvement

Twitter

Archives

Flickr Photos

www.flickr.com
This is a Flickr badge showing public photos and videos from Nick_Schweitzer. Make your own badge here.

Standard Disclaimers

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2012 Nick Schweitzer