Skip to content

Instantly share code, notes, and snippets.

@eriky
Last active February 6, 2021 02:10
Show Gist options
  • Save eriky/0de249619e6db10fa47b7d47082b4c36 to your computer and use it in GitHub Desktop.
Save eriky/0de249619e6db10fa47b7d47082b4c36 to your computer and use it in GitHub Desktop.
import time
# A CPU heavy calculation, just
# as an example. This can be
# anything you like
def heavy(n, myid):
for x in range(1, n):
for y in range(1, n):
x**y
print(myid, "is done")
def sequential(n):
for i in range(n):
heavy(500, i)
if __name__ == "__main__":
start = time.time()
sequential(80)
end = time.time()
print("Took: ", end - start)
# On my system, this takes
# about 46 seconds.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment