Created
January 9, 2010 12:23
-
-
Save hktechn0/272875 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/usr/bin/env python | |
import datetime | |
loop = 500000 | |
a = str() | |
s = datetime.datetime.now() | |
for i in range(loop): | |
for c in range(0x20, 0x7f): | |
a += chr(c) | |
e = datetime.datetime.now() | |
print e - s | |
b = list() | |
s = datetime.datetime.now() | |
for i in range(loop): | |
for c in range(0x20, 0x7f): | |
b.append(chr(c)) | |
b = ''.join(b) | |
e = datetime.datetime.now() | |
print e - s | |
# $ time python strjoin_test.py | |
# 0:00:18.512737 | |
# 0:00:20.663510 | |
# python strjoin_test.py 27.92s user 11.05s system 99% cpu 39.242 total |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment