« The Internet says... | Main | FireWire moving forward »

November 15, 2009

TrackBack

TrackBack URL for this entry:
http://www.typepad.com/services/trackback/6a00d8341d80a253ef0128759f2827970c

Listed below are links to weblogs that reference Rules of program optimization:

Comments

Giorgos Keramidas

Excellent points!

Another thing I found useful when applying optimizations is:

Use unit tests.

I can't really remember all the times a unit test has saved the day when I'm applying refactoring changes or optimizations. One of the most recent examples is a library function that parses pairs of IPv4 network address and (optional) address-masks. By adding units tests that should pass for the most common formats ("10/8", "10.0/12", "192.168.1/16" or even "0/0" and "0/255.255.255.0") I uncovered a bug that had been lurking in the code since the last time I touched it this summer.

Having a set of unit tests that were all successful I started making the optimization I had in mind. At the end of the day I knew that I had not broken any of the working cases, and the optimizations were committed and pushed to our main branch.

This and other past experiences make me feel strange and very very cautious every time I have to add optimizations to a piece of code without an accompanying test suite.

BTW, is the video of prof. Spinellis online in a publicly accessible place? Can we fetch and view it too?

Dimitris Staikos

This is the link to the video (the talk is in Greek): https://www323.livemeeting.com/cc/usergroups/view?id=dnzad1-1

You are absolutely right about the unit tests. They are needed for all kinds of refactorings, not just optimizations.

The comments to this entry are closed.