Last active
April 2, 2017 03:35
-
-
Save bast/535b2662a1c9b91c9347 to your computer and use it in GitHub Desktop.
Script to plot some Amdahl's law curves.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright (c) 2015 Radovan Bast | |
# Licensed under the MIT license - http://opensource.org/licenses/MIT | |
from pylab import * | |
def get_amdahl(p, n): | |
s = 1.0/((1.0 - p) + (p/n)) | |
return s | |
def get_function(p, num_elements): | |
return map(get_amdahl, [p]*num_elements, range(1, num_elements+1)) | |
m = 60 | |
plot(get_function(1.00, m), label='ideal', linewidth=2.0) | |
plot(get_function(0.99, m), label='99%', linewidth=2.0) | |
plot(get_function(0.90, m), label='90%', linewidth=2.0) | |
plot(get_function(0.75, m), label='75%', linewidth=2.0) | |
plot(get_function(0.50, m), label='50%', linewidth=2.0) | |
grid(True) | |
ylabel("Speedup") | |
xlabel("Number of processes") | |
legend() | |
savefig("amdahl.png", dpi=72) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment