Last active
December 24, 2015 13:59
-
-
Save georgefs/6809768 to your computer and use it in GitHub Desktop.
simple test
This file contains 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
try: | |
from cStringIO import StringIO | |
except: | |
from io import StringIO | |
from datetime import datetime | |
def test_join(): | |
data = [] | |
for i in range(1000000): | |
data.append(str(i)) | |
data = "".join(data) | |
def test_connect(): | |
data = "" | |
for i in range(1000000): | |
data += str(i) | |
def test_stringio(): | |
data = StringIO() | |
for i in range(1000000): | |
data.write(str(i)) | |
now = datetime.now() | |
test_join() | |
now2 = datetime.now() | |
test_connect() | |
now3 = datetime.now() | |
test_stringio() | |
now4 = datetime.now() | |
print('test_join') | |
print(now2 - now) | |
print('test_connect') | |
print(now3 - now2) | |
print('test_stringio') | |
print(now4 - now3) |
python3
➜ /tmp python3 test.py
test_join
0:00:00.435748
test_connect
0:00:00.330496
test_stringio
0:00:00.346228
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
python2.7