Thursday, June 19, 2008

Performance measurements

When attempting to make your code faster the only thing that matters is time. What I mean by that is you have to time the operation you are trying to improve before you make any changes then make your changes then time it again. Did it get faster then your are on the right track. The reason I point out what might be obvious to some of you is that all to often as developers we skip the timing step and try to make performance improvements on how we think the system behaves. With the virtual machines and out-of-order processors what we think will happen and what does happen at the execution level don't match up. Which is why what does matter is "Did I make the code run faster".

Some notes about communicating performance increases. Let say you have an operation that originally processes 46 records per second and you improve it to process 161/sec. You can either say it is:
- 3.5 times faster (161 / 46)
- 250% faster ((161 / 46) - 1 * 100)

If the original run completed in 543.5 seconds and the improved one completed in 155.3 seconds you can say it requires
- 71.4% less time ((543.5 - 155.3) / 543.5) * 100

No comments: