Skip to content

Instantly share code, notes, and snippets.

@MatrixFrog
Created December 26, 2010 20:45
Show Gist options
  • Save MatrixFrog/755616 to your computer and use it in GitHub Desktop.
Save MatrixFrog/755616 to your computer and use it in GitHub Desktop.
import time
import sys
arg = sys.argv[1];
def testFun():
pass
if arg == 'class':
class testClass:
def __init__(self, a, b):
self.a = a
self.b = b
test = testClass(1, testFun)
t = time.time()
for i in xrange(30000000):
a = test.a
a = test.b
print time.time() - t
elif arg == 'array':
testArr = [1, testFun]
t = time.time()
for i in xrange(30000000):
a = testArr[0]
a = testArr[1]
print time.time() - t
else:
print 'type "class" or "array"'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment