Skip to content

Instantly share code, notes, and snippets.

@shiftkey
Created January 29, 2014 04:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shiftkey/8681919 to your computer and use it in GitHub Desktop.
Save shiftkey/8681919 to your computer and use it in GitHub Desktop.
Re-testing http://blogs.msdn.com/b/vancem/archive/2006/10/01/779503.aspx on a modern machine (VM inside a MBP)
# .NET Framework 2.0
Data units of msec resolution = 0.365714 usec
10 typeof(string) : count: 1000000 26.349 +- 4% msec
10 typeof(string).TypeHandle : count: 1000000 27.436 +- 4% msec
10 anObj.GetType() == type : count: 1000000 35.330 +- 2% msec
10 Type.GetTypeHandle(obj).Equals(tHnd) : count: 1000000 28.136 +- 3% msec
10 anObj.GetType() == typeof(string) : count: 1000000 2.254 +- 7% msec
10 (anObj is string) : count: 1000000 8.841 +- 4% msec
# .NET Framework 4
Data units of msec resolution = 0.365714 usec
10 typeof(string) : count: 1000000 14.737 +- 1% msec
10 typeof(string).TypeHandle : count: 1000000 33.800 +- 4% msec
10 anObj.GetType() == type : count: 1000000 4.546 +- 1% msec
10 Type.GetTypeHandle(obj).Equals(tHnd) : count: 1000000 63.028 +- 1% msec
10 anObj.GetType() == typeof(string) : count: 1000000 2.691 +- 3% msec
10 (anObj is string) : count: 1000000 2.283 +- 2% msec
# .NET Framework 4.5
Data units of msec resolution = 0.365714 usec
10 typeof(string) : count: 1000000 14.813 +- 1% msec
10 typeof(string).TypeHandle : count: 1000000 34.945 +- 3% msec
10 anObj.GetType() == type : count: 1000000 4.636 +- 9% msec
10 Type.GetTypeHandle(obj).Equals(tHnd) : count: 1000000 63.954 +- 5% msec
10 anObj.GetType() == typeof(string) : count: 1000000 2.826 +- 7% msec
10 (anObj is string) : count: 1000000 2.334 +- 9% msec
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment