Skip to content

Instantly share code, notes, and snippets.

@littleq0903
Forked from georgefs/test.py
Created October 31, 2013 03:56
Show Gist options
  • Save littleq0903/7244173 to your computer and use it in GitHub Desktop.
Save littleq0903/7244173 to your computer and use it in GitHub Desktop.
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment