A code monkey randomly typing on a keyboard for an infinite amount of time will almost surely produce brilliance (almost).

Putting the Nerd in It: Calculating Speedup with Amdahl’s Law

Posted: January 5th, 2010 | Author: Huyen Tue Dao | Filed under: Development | Tags: , , , | No Comments »

Okay, I promise I will try very hard not to bore you in the next few hundred words. But basically I just want to present a way of determining how much faster a system will be if you speedup one (or more) or its components.

Say that you have an enhancement that can be made to speedup some part of an application.
And say that you know how much runtime you can save with the enhancement.
And say that you know what fraction of the total runtime that part of the application takes up.
Then you can determine how much you will speedup the application as a whole by making that enhancement.

Why is this valuable?

You might be in a situation where you have to justify time and effort spent (and fancy formulas help to dazzle the crowd).
You might have two different enhancements or changes that could be made but only have time to do one. Which should you choose?
You might just want to know how badass your idea really is.

So, I present to you Amdahl’s Law:

Fraction_A = Fraction of application runtime taken up by component A

Speedup_A = {Runtime of A with enhancement}/{Runtime of A without enhancement}

Runtime_new = Runtime_old * ((1 - Fraction_A) + Fraction_A/Speedup_A)

Speedup_Overall = {Runtime_new}/{Runtime_old} = 1 / {(1 - Fraction_A) + Fraction_A/Speedup_A}

Formulas borrowed lovingly from Hennessy + Patterson’s Computer Architecture: A Quantitative Approach

You could use this formula for any other performance metric.  For example, if you were more concerned with memory consumption, the formulas still hold: just replace “runtime” with “memory use” and “speedup” with “memory reduction.”

Hope you find this helpful someday.  I’ll try to keep so many equations out of the next post. :)