Program Optimization - Program Optimization When Writing a...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
Program Optimization
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
When Writing a Program 1. Keep It Simple Write the simplest implementation that provides the functionality you need. 2. Test Test the Program to make sure that it does what it is supposed to do. 3. Refactor Make your code simple and readable so other people can easily understand it and maintin it. 4. Optimize program only if necessary Only if your code does not run fast enough, profile it with an execution profiling tool to find where it spends most of the time. You will be surprised that maybe about 0.05% of your code needs to be optimized.
Background image of page 2
Premature Optimization Programmers often optimize in advance parts of the code that do not need to be optimized. Only small portions of code need to be optimized. You will be able to leave most of the code intact, well written, easy to read. This is good because optimizing code may make the code difficult to understand.
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Profiling Tools Code Instrumentation Add instructions into the code before a
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/30/2012 for the course CS 252 taught by Professor Gustavorodriguez during the Fall '11 term at Purdue University-West Lafayette.

Page1 / 7

Program Optimization - Program Optimization When Writing a...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online