Log in

No account? Create an account
Adventures in Engineering
The wanderings of a modern ronin.

Ben Cantrick
  Date: 2006-04-21 15:06
  Subject:   [Digg] Five truths about code optimization.
Although my change made only a tiny difference in the speed of the code, I did gain something. I was reminded that when optimizing, you need to profile first and code later. I was so darned sure it was the serialization that I didn't bother to profile the code. Well OK, so I took my change out and profiled the code. Surprise! The culprit turned out to be in the way we were reading and writing the data to the file. Our IO was completely unbuffered -- we were laboriously reading and writing all that data one byte at a time. Compared to huge IO overhead, the serialization was a drop in the bucket.

My experience is not unusual: Your best guess as to what is making this program a pig is usually wrong. The only way to know is to run your code with a profiler and see which bits are the slow ones.

Post A Comment | | Link

May 2015