Skip to content

Instantly share code, notes, and snippets.

@georgefs
Last active December 24, 2015 13:59
Show Gist options
  • Save georgefs/6809768 to your computer and use it in GitHub Desktop.
Save georgefs/6809768 to your computer and use it in GitHub Desktop.
simple test
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)
@georgefs
Copy link
Author

georgefs commented Oct 3, 2013

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