Each day we all use everyday things
to accomplish everyday tasks. For programmers our everyday tools are
arrays, loops and OOP constructs. We all use them, but are we all aware
of the performance implications? In his talk, The Performance of
Everyday Things, Jeffery Richter asks the question, "Do you know what
goes on under the hood in .NET?"
Performance of an application impacts user experience in dramatic
ways. When software is slow user’s frustrations soar and create an
anxious user experience. In this podcast our guest, renown author, consultant and co-founder of Wintellect Jeffrey Richter sheds some light on how everyday programming practices can have a significant effect on application performance.
The following is an outline of Jeffrey’s talking points during the interview:
- CPUs are not increasing in speed at the same rate as in the past
- Tomorrow’s higher-performing software will take advantage of multi-threading
- Learn multi-threading by reading books and building a proof-of-concept
- Optimize for performance when necessary
- BUT – learn about performance implications now so you can prepare future projects for better performance
While researching this material, Jeffrey found some details surprising on how affected performance in .NET:
- Static methods on delegates are slower than instance methods
- Delegates are optimized in the CLR for instance methods
Tips & Tricks
Quick Access to Methods via Reflection
If you must use reflection to call a method, discover the method once while reflecting and then use Delegate.CreateDelegate for future calls.
Skip foreach and use ForEach
The foreach construct will perform the following operations upon each use:
- Call GetEnumerator and create an instance of the collection object on the heap (requiring garbage collection)
- Call MoveNext during each iteration
- Call Current during each iteration
In .NET 2.0 some of the collection classes feature the ForEach method which requires a delegate as a method argument. This approach not only performs better, but also cleans up your code.
See Jeffrey Live
Jeffrey is speaking at the Microsoft campus during the Devscovery conference in August 2008.
Rockstar Dynamic Data Customizations
We recently released the Scorecard series which will teach you to create custom layouts for Dynamic Data websites.
In addition you learn to use Infragistics controls to power the
scaffolding. This five-part series that takes you step-by-step from
configuration to the final UI customizations. Check it out!