# How to calculate the miss ratio of a cache

I know how to calculate the CPI or cycles per instruction from the hit and miss ratios, but I do not know exactly how to calculate the miss ratio that would be 1 - hit ratio if I am not wrong. I know that the hit ratio is calculated dividing hits / accesses, but the problem says that given the number of hits and misses, calculate the miss ratio.

My reasoning is that having the number of hits and misses, we have actually the number of accesses = hits + misses, so the actual formula would be:

hit_ratio = hits / (hits + misses)

So the miss ratio would be

miss_ratio = 1 - hit_ratio

If my reasoning is correct, right?

What is the hit and miss latencies? Because I need them to calculate the mean access time using the hit and the miss ratios and the hit and the miss latencies (in cycles)...

Yes. The hit ratio is the fraction of accesses which are a hit. The miss ratio is the fraction of accesses which are a miss. It holds that $$\text{miss rate} = 1-\text{hit rate}.$$
• Can you show me a simple example of how would you calculate the mean access time having of I told you? – nbro Nov 2 '14 at 9:15
• Well, we know that $X * 0.30$ is the total number of cycles where we have a hit, and that respectively $Y * 0.70$ is the total number of cycles where we have a miss, therefore the total number of cycles is the sum of both: total_number_of_cycles = $X * 0.30$ + $Y * 0.70$. But we still not have an average of something, we need to divide it for the total time: mean_access_time = total_number_of_cycles / 1.0 , Is it right? – nbro Nov 2 '14 at 15:10