Skip to content

Instantly share code, notes, and snippets.

@StuartFarmer
Created May 30, 2019 18:32
Show Gist options
  • Save StuartFarmer/7b13a9f077342ca4fe181ce6303c5251 to your computer and use it in GitHub Desktop.
Save StuartFarmer/7b13a9f077342ca4fe181ce6303c5251 to your computer and use it in GitHub Desktop.
import timeit
setup = '''
class c:
def __enter__(self):
pass
def __exit__(self, type, value, traceback):
pass
'''
statement = '''
with c():
pass
'''
w = timeit.timeit(statement, setup=setup)
print('With setup and cleanup time: {}'.format(w))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment