# CPU Performance

Please, help me to understand the mathematics behind the following formula of CPI. Why do we calculate CPI the way it's done on the pic? • What's CPI? Please make your question self-contained by defining the relevant terms, and please replace the image by text so your question is searchable and accessible to partially sighted people. Feb 7 '15 at 19:43
• What self-study have you done? CPI is explained in many architecture textbooks. There is little point in us repeating that explanation here. We expect you to do a significant amount of self-study before asking, so you can ask a more informed question....
– D.W.
Feb 8 '15 at 2:13
• It looks like it is just the average number of cycles per instruction. Jun 22 '15 at 12:46

CPI is the average number of cycles per instruction. The CPI is the expected value of $C(R)$, where $R$ is a random instruction, and for an instruction $r$, $C(r)$ is the number of clock cycles that $r$ takes. The table gives you the distribution of $R$ and the function $C$, from which you can calculate the expectation according to its definition (which matches the intuitive concept of average number of cycles per instruction), namely $$\mathbb{E}[C(R)] = \sum_r C(r) \Pr[R = r].$$ That's the computation detailed in the answer.