TheChaseMan's Frenetic SoapBox

Always looking for better ways to do things...

Quote of the Day

This quote is taken from a presentation given by Rico Mariani called Designing .NET Class Libraries: CLR Performance Tips

People use this phrase, "Premature optimization is the root of all evil," as an excuse not to think about performance at all in their early planning...Say I wanted to code a sort..so I say, "Oh, no, I'm not going to invest in my sorting algorithm just now. That would be premature. What I'm going to do is code it up the easy way first and then make it fast later."... So they write the easiest sort that they can think of: bubble sort. Great. Got that bubble sort in there. It's nice and easy. Then later they find out it's too slow. Big surprise there. Stunning development: BubbleSort about the worst sort that isn't completely stupid...so they've got to replace it. So they go pick up Quicksort. Now, let me ask you, if you were in a position where you needed to substitute the BubbleSort algorithm--and I'm using BubbleSort as kind of the proxy for the problem here--If you were substituting your BubbleSort with a Quicksort, how much learning did you get out of coding up the BubbleSort? Are you going to just tune it up? Are you going to, "Oh, I'll just tune it up right all day, and I'll turn it into a Quicksort"?

You're not going to tune it up. You're going to throw it out, right? I mean there's not a darn thing in common between those two things except for the greater-than test. The BubbleSort is gone and pitched out the window and you're basically writing a whole new sort from scratch, and you spent a whole lot of time maybe, living with your BubbleSort and planning around it or not thinking about what you need to be doing, and now at the end, you find yourself having to discover the Quicksort...But a lot of times, there is no off-the-shelf that you're going to plug in. Your design is fundamentally flawed, and you at the last minute are going to have to go back to the drawing board and figure out how the heck you're going to do something that's plug-compatible with the "easiest way" that is going to fit into your overall system. You can easily find yourself doomed.

...Make sure that you have the right algorithm in place and that you have a plan in place that lets you be substantially likely to succeed against your performance goals. That's performance planning.


Digg!

posted on Sunday, March 06, 2005 12:01 PM

Feedback

No comments posted yet.