This lecture gives an introduction to the concept of code optimization. The topic is of primary importance within the particle physics domain due to the continously increase of the amount of computation needed in different applications combined with the availability of new, more advanced processor architectures. t is however very wide and can have a variety of aspects. After a brief introduction on common methods used to obtain information about program characteristics and typical bottlenecks, we will focus on specific techniques to define and improve application efficiency used in the GeantV project, a prototype code for the simulation of particle interactions with matte