Wednesday, April 16, 2008

The smallwig theory of optimization

There are three kinds of optimization.
  1. Optimization by using a more sensible overall approach.
  2. Optimization by making the code less weird.
  3. Optimization by making the code more weird.

To make a type 3 optimization, your burdens are six:
  1. Thou shalt have excellent, comprehensive unit tests.
  3. Thou shalt demonstrate that your change improves the benchmark.
  4. Thou shalt successfully argue that this improvement really matters.
  5. Thou shalt comment the code.
In all things, remember these truths:
  1. Your brain is a terrible profiler.
  2. Hotspot will outsmart you.
  3. It just doesn't matter, until it matters.
If you believe this post, please spread the word!


Fatih Coşkun said...

I believe; starred.

artsrc said...

The remedy for premature optimization is to expedite knowledge.

Elliotte Rusty Harold said...

I'd argue that #1 and #2 aren't really optimizations at all. Using a more sensible approach and/or making the code less weird are benefits in and of themselves, irrespective of their effect on performance. They are things you would do even if they made the code slower, and refusing to do them when they make the code slower is a case of premature optimization. Of course if they do make the code faster (and they usually do) then so much the better; and even if they don't make the code faster immediately, these sorts of improvements usually make the code more amenable to carefully planned out, non-premature optimization later.

Elliotte Rusty Harold said...

Also, what about option 2.5? Optimization that neither makes the code less nor more weird, simply different? My gut is that that is premature, if or no other reason that it wastes time that could be spent elsewhere.

Jim Xochellis said...

Very nice and useful!

Personally, I am very interesting to find out what is really happening in the real word nowadays. Do the professional programmers of our generation optimize too late or too early? What is most frequent?

Do you happen to know any surveys
or polls which can provide objective information regarding the way the programmers use to optimize nowadays?

Thank you very much,
Jim Xochellis


yi said...


combattery84 said...

Dell Inspiron 600m battery
Dell Inspiron 8100 Battery
Dell Y9943 battery
Dell Inspiron 1521 battery
Dell Inspiron 510m battery
Dell Latitude D500 battery
Dell Latitude D520 battery
Dell GD761 battery
Dell NF343 battery
Dell D5318 battery
Dell G5260 battery
Dell Inspiron 9200 battery
Dell Latitude C500 battery
Dell HD438 Battery
Dell GK479 battery
Dell PC764 battery
Dell KD476 Battery
Dell Inspiron 1150 battery
Dell inspiron 8500 battery
Dell Inspiron 4100 battery
Dell Inspiron 4000 battery
Dell Inspiron 8200 battery
Dell FK890 battery
Dell Inspiron 1721 battery

Dell Inspiron 1300 Battery
Dell Inspiron 1520 Battery
Dell Latitude D600 Battery
Dell XPS M1330 battery
Dell Latitude D531N Battery
Dell INSPIRON 6000 battery
Dell INSPIRON 6400 Battery
Dell Inspiron 9300 battery

dainfo said...

workout at home with dumbbells
at home workouts
lose weight at home
abs workout at home
exercise machines at a gym
chest workout at home
get fit with exercise
how to exercise at home
run a marathon to shed pounds and improve cardio
how to lose weight at home
a healthy heart comes with exercise
medicine ball abs
fatigue your muscles by using weights or your body
upper body workout at home
be sure to hydrate your muscles as often as possible
dandruff home remedy
where to buy venapro
buy venapro
venapro reviews
venapro review
best tooth whitening system
bleaching your teeth
teeth bleaching products
teeth bleaching trays
tooth whitening bleach

Young said...

These onitsuka tiger online shop are buy asics tigers online awesome, tiger asics shoes but huge! I cheap onitsuka tiger had to asics tiger australia return twice cheap onitsuka tiger shoes because they onitsuka tiger zodiac were so big asics tiger I normally onitsuka tiger australia wear a 7.5 but ended up fitting asics onitsuka tiger mexico nicely into a tiger mexico 66. Other than that, onitsuka tiger shoes australia they look spiffy, seem onitsuka tiger mexico 66 black well made tiger mini cooper only had asics onitsuka so far, and they tiger shoes australia are still holding buy onitsuka tiger shoes online together mexico 66 perfectly, onitsuka tiger yellow black as they should be), and onitsuka tiger tokyo they came onitsuka tiger ultimate 81 with two asics onitsuka tiger trainers colors of laces asics kinsei. I onitsuka tiger mexico 66 yellow black would certainly tiger shoes onitsuka buy other onitsuka tiger sale colors of discount asics running shoes that I know onitsuka tiger mexico 66 my correct onitsuka tiger black white this brand buy onitsuka tiger shoes is a good asics international shipping best online onitsuka tiger online store

Cheapmonclerjacket said...


Ethan Kleeberg said...


Computer Accessories | buy webcam

Berrty Gawill said...

Computer viruses could be a nightmare. Some can wipe out the knowledge with a challenging push, tie up traffic with a computer community for hrs, convert an innocent machine into a zombie and replicate and mail by themselves to other computer systems. If you've got hardly ever had a machine drop victim to the laptop or computer virus, you could possibly surprise exactly what the fuss is about. Though the issue is easy to understand -- in accordance to Buyer Stories, computer viruses assisted lead to $8.5 billion in client losses in 2008 [source: MarketWatch]. Computer viruses are just just one type of on the internet threat, but they're arguably the best known from the latitude e6510 battery
Dell inspiron 6400 Battery
Dell inspiron e1505 Battery F
Dell latitude d620 Battery
Dell latitude d610 Battery

Jerry Gene said...


