Advertisement
Ambamore

Untitled

Feb 10th, 2022
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.63 KB | None | 0 0
  1. def get_t_serial(n, c):
  2.     return (20*(n**2)+c)
  3. def get_t_parallel(n, c, p):
  4.     return ((20*(n**2))/p + c + 100*p)
  5.  
  6. def get_speedup(n, c, p):
  7.     t_serial = get_t_serial(n, c)
  8.     t_parallel = get_t_parallel(n, c, p)
  9.  
  10.     return t_serial/t_parallel
  11.  
  12. def get_efficiency(n, c, p):
  13.     t_serial = get_t_serial(n, c)
  14.     t_parallel = get_t_parallel(n, c, p)
  15.  
  16.     return t_serial/(t_parallel*p)
  17.  
  18. def main():
  19.     C = 100
  20.     x = 6
  21.     for y in range(9):
  22.         print("N: 2^", x, "| P: 2^", y, "| Speedup:", get_speedup(2**x, C, 2**y), "| Efficiency:", get_efficiency(2**x, C, 2**y))
  23.  
  24. if __name__ == '__main__':
  25.     main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement