Latest Tweet:
  • Loading...

Last week I blogged about a performance problem I helped a colleague debug. The root of the problem was reflection based cloning of objects. Reflection based cloning can be great for maintainability and productivity, but in some cases you might get into troubles. At least if you don't know that the classes you're using are using reflection.

Anders Norås followed up on my post and blogged about other ways to implement object cloning. Yesterday he posted a great example on how to get blazing fast reflection in .NET. In his post Anders discusses how you can use the CodeDOM to generate reflection optimizers and compile them to in-memory assemblies . An even better alternative is the Lightweight Code Generation (LCG) feature of .NET 2.0. In his example cloning a customer class one million times takes about one minutte using pure reflection. The bytecode enhanced reflection takes about 175 milliseconds. Now that's some serious performance. 

"...You have a couple of options for doing optimized reflection on .NET. In general you will use the CodeDOM to generate the optimizers on .NET 1.x, while you'll use Lightweight Code Generation (LCG) on .NET 2.0. LCG bridges the gap between purely dynamic invocations and statically bound calls. The LCG feature provides the means for generating dynamic methods at runtime..." (from Anders Norås blog)

Anders has several other interesting posts on both Java and .NET development. His posts on DSL's and a LINQ implementation on Java is really interesting reading well worth checking out.

<August 2010>
SunMonTueWedThuFriSat
25262728293031
1234567
891011121314
15161718192021
22232425262728
2930311234