Linked by Thom Holwerda on Fri 13th Feb 2009 16:19 UTC, submitted by ShlomiFish
General Development There's a new essay called "Optimizing Code for Speed" available on Shlomi Fish's site. It covers the motivation, methods and terminology of optimizing code, and provides many links and examples to illustrate this important subject.
Thread beginning with comment 349216
To read all comments associated with this story, please click here.
Comment by wkleunen
by wkleunen on Mon 16th Feb 2009 09:49 UTC
wkleunen
Member since:
2006-05-04

Copy-on-write is not always a good optimization. In case of multithreaded programs the locking kills your performance.

Think about your optimizations, and don't assume that a optimization will work in all cases. And second, time your optimization to see that it is really an improvement.

Even complexity optimizations don't always work out the way you think. Maybe for N=1000 a N Log N sort is faster than a N^2 sort, but for N=5, maybe the N^2 sort if both smaller and faster.

Have a look at this article as well:
http://www.gotw.ca/publications/optimizations.htm

Edited 2009-02-16 09:57 UTC

Reply Score: 1

RE: Comment by wkleunen
by m3metix on Mon 16th Feb 2009 15:21 in reply to "Comment by wkleunen"
m3metix Member since:
2009-02-16


Even complexity optimizations don't always work out the way you think. Maybe for N=1000 a N Log N sort is faster than a N^2 sort, but for N=5, maybe the N^2 sort if both smaller and faster.


This is true. I have used bubble sort, which is O(N^2), in a case where N was guaranteed to always be 5 (a hand of 5 cards), since it is a simple algorithm to write and understand and the speed was more than adequate.

Reply Parent Score: 1