Skip to content

Instantly share code, notes, and snippets.

@natemurthy
Last active August 29, 2015 14:02
Show Gist options
  • Save natemurthy/737e61d23c71946f3062 to your computer and use it in GitHub Desktop.
Save natemurthy/737e61d23c71946f3062 to your computer and use it in GitHub Desktop.
"""
Each 'import' statement demarcates a separate file
"""
# map.py
import time
start = time.time()
print("\n(Map) multiplying 60 million elements by 2")
dbls=map(lambda n: 2*n, range(60000000))
print("(Reduce) sum: %d" % sum(dbls))
end = time.time()
print("Total MapReduce time: %f" % (end-start))
# gen_map.py
import time
start = time.time()
print("\n(Map) multiplying 60 million elements by 2")
dbls=[2*n for n in range(60000000)]
print("(Reduce) sum: %d" % sum(dbls))
end = time.time()
print("Total MapReduce time: %f" % (end-start))
# numpy_map.py
import numpy as np
import time
start = time.time()
print("\n(Map) multiplying 60 million elements by 2")
dbls=np.arange(60000000)*2
print("(Reduce) sum: %d" % sum(dbls))
end = time.time()
print("Total MapReduce time: %f" % (end-start))
# pandas_map.py
import pandas as pd
import time
start = time.time()
print("\n(Map) multiplying 60 million elements by 2")
dbls=pd.Series(range(60000000))*2
print("(Reduce) sum: %d" % dbls.sum())
end = time.time()
print("Total MapReduce time: %f" % (end-start))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment