Cache Hit Ratio Calculator

Compute cache hit ratio, miss rate and average memory access time from hit and miss counts.

Technology and NetUpdated 2026-11-203 min read
Cache Hit Ratio Calculator
Time to return data when the reference is a hit.
Extra time beyond the hit time needed to service a miss.
Hit ratio
...
Miss rate...
Average memory access time...

What it does

A cache sits between the processor and main memory to keep recently used data close at hand. When a requested item is found in the cache the access is a hit and returns quickly. When it is not there the access is a miss, and the data must be fetched from further away. The hit ratio is simply the share of accesses that were hits, and it is the first number most people look at when judging a cache.

Hit ratio alone does not tell the whole story. A cache with a 99 percent hit ratio can still be slow if each miss costs a great deal of time. Average memory access time combines the two effects. It adds the hit time to the miss rate multiplied by the miss penalty, giving a single figure in nanoseconds that is much closer to what the processor experiences.

The miss penalty in this formula is the extra time needed to service a miss beyond the normal hit time. That definition matters. If your source reports the full time for a miss including the initial lookup, subtract the hit time before entering the penalty, or the average will be too high.

The relationship is linear in miss rate but can be steep. With a 100 ns miss penalty, each additional percentage point of miss rate adds one nanosecond to the average. With a penalty of several hundred cycles, the same one percent can add several nanoseconds and erase the benefit of a faster hit time.

This is a single level model. Real processors usually have several cache levels, so the penalty for a level one miss is itself an average that includes the lower level hit time and its own miss penalty. Write policies, separate instruction and data caches, and overlapping requests can also change the accounting. Use this tool as the building block rather than a complete processor model.

How to use

  1. Count the number of hits and misses over the same measurement window.
  2. Enter the hit time in nanoseconds for the cache you are studying.
  3. Enter the extra miss penalty in nanoseconds, beyond the hit time.
  4. Read the hit ratio, miss rate and average memory access time.
  5. Change one input at a time to see which lever helps most.
  6. For multilevel caches, build from the lowest level upward and feed the lower level average back as the penalty.

Formula

Hit ratio = hits / (hits + misses). Miss rate = misses / (hits + misses). AMAT = hit time + miss rate x miss penalty.
Hits
Number of accesses found in the cache.
Misses
Number of accesses not found in the cache.
Hit time
Time to return data on a hit, in nanoseconds.
Miss penalty
Extra time to service a miss beyond the hit time, in nanoseconds.
AMAT
Average memory access time, in nanoseconds.

Hits and misses must both be whole numbers and cannot both be zero, because there would be no access from which to form a ratio. Hit ratio and miss rate always add to 100 percent, since every reference is either a hit or a miss. The tool displays the average access time with three decimal places so small differences remain visible.

Worked example

Example: 900 hits and 100 misses

Defaults: 900 hits, 100 misses, hit time 1 ns and miss penalty 100 ns.

  1. Add the accesses: 900 + 100 = 1000.
  2. Divide hits by total: 900 / 1000 = 0.90, so the hit ratio is 90.00 %.
  3. Divide misses by total: 100 / 1000 = 0.10, so the miss rate is 10.00 %.
  4. Multiply miss rate by penalty: 0.10 x 100 = 10 ns.
  5. Add the hit time: 1 + 10 = 11.000 ns.
  6. The tool shows 90.00 %, 10.00 % and 11.000 ns.

Reference table

Average access time with a 1 ns hit time and a 100 ns miss penalty
Hit ratioMiss rateAMAT
100 %0 %1.000 ns
99 %1 %2.000 ns
95 %5 %6.000 ns
90 %10 %11.000 ns
50 %50 %51.000 ns

Limits

  • Models a single cache level, so a miss penalty for a higher level must already include lower level behaviour.
  • Assumes the miss penalty is extra time beyond the hit time.
  • Ignores overlap, write buffers and separate instruction and data streams.
  • Uses simple counts, so the result describes a measurement window rather than a guarantee for future workloads.

Common mistakes

  • Entering the total miss service time instead of the extra miss penalty.
  • Dividing hits by misses rather than by hits plus misses.
  • Mixing units between hit time and miss penalty.
  • Assuming a higher hit ratio always beats a lower miss penalty without checking the average.
  • Using non whole numbers for hit and miss counts, which the tool rejects.

Try it yourself

Quick checks. Answers sit tucked under each question.

9500 hits, 500 misses, 2 ns hit time and 80 ns miss penalty. What does the tool show?

Total accesses are 10000, so hit ratio is 95.00 % and miss rate is 5.00 %. AMAT = 2 + 0.05 x 80 = 6.000 ns.

100 hits, 900 misses, 1 ns hit time and 200 ns miss penalty. What is the average?

Hit ratio is 10.00 % and miss rate is 90.00 %. AMAT = 1 + 0.9 x 200 = 181.000 ns.

What happens if hits and misses are both zero?

The tool returns the error Hits plus misses must be above 0, because a ratio with no accesses is undefined.

Questions

What is a good hit ratio?

It depends on the level and workload. Level one data caches often exceed 90 percent, but the miss penalty matters just as much as the ratio itself.

Is miss rate just one minus hit ratio?

Yes, when every access is classified as either a hit or a miss. The tool prints both values and they always add to 100 percent.

What exactly is the miss penalty?

It is the additional time needed to fetch the data after a miss, measured beyond the time already counted as the hit time.

Why use nanoseconds?

It keeps the numbers readable and matches common memory timing figures. Any consistent time unit would give the same ratio, but the average would be in that unit.

Can I use cycle counts instead?

Yes, as long as both hit time and miss penalty are in cycles. The displayed average will then be in cycles rather than nanoseconds.

How do I extend this to two cache levels?

Compute the level two average first, then use it as the miss penalty for level one. That recursively gives the combined average access time.

Sources

How this page was checked. The formula above was matched against the cited sources, and the worked example was run through the tool on this page before publishing. If you spot an error, contact us so we can fix it and note the correction.