Editorials

Code Optimization

Many have commented on the posting regarding a recent comparison of Java to Dot Net for performance of a specific algorithm. We seem to have a consensus that the majority of the time application performance is not determined by a single section of code, but by the application as a whole.

Today I wanted to include some coding techniques that often make more difference than the speed of the engine for doing math.

To start with, Tim writes, “I have seen many cases where just taking repeated calculations out of loops has seen some operations drop from minutes to seconds.”

I have seen application performance degrade when the scope of work across the entire stack is too small. For example, I have seen some applications update a single row in a table multiple times, once for each column attribute being updated. It is much more efficient to update an entire row, or better yet, merge changes to an entire set of rows, than perform each attribute one at a time.

Learn to use lazy loading, caching and queuing techniques allowing end users to have optimized experience while potentially long running processes are working in the background.

Learn to use parallel programming techniques taking advantage of multiple cores on your CPU. For example, the Parallel ForEach in Dot Net can potentially increase the performance of your application without a lot of heavy lifting on your part to make, maintain and manage multiple threads.

These are a few brainstorms off the top of my head. Why not share your ideas? Do you have some favorite code optimization techniques you like to use? Share them in comments here, or drop me an Email to be included later.

Cheers,

Ben