Skip to content

Instantly share code, notes, and snippets.

@seungjin
Created May 1, 2011 05:04
Show Gist options
  • Select an option

  • Save seungjin/950269 to your computer and use it in GitHub Desktop.

Select an option

Save seungjin/950269 to your computer and use it in GitHub Desktop.
speed test with different expressions
#!/opt/local/bin/python
from datetime import datetime
r1 = []
for a in range(1,10001) :
begin = datetime.now()
reduce(lambda x,y: x+" " +y,map(lambda x: x.upper(), ["diversity","is","good"]))
end = datetime.now()
r1.append(end-begin)
print reduce(lambda x,y: x+y, r1)/len(r1)
#!/opt/local/bin/python
from datetime import datetime
r2 = []
for a in range(1,10001) :
begin = datetime.now()
' '.join(["diversity","is","good"]).upper()
end = datetime.now()
r2.append(end-begin)
print reduce(lambda x,y: x+y, r2)/len(r2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment