Skip to content

Instantly share code, notes, and snippets.

@lega911
Created March 18, 2014 11:07
Show Gist options
  • Save lega911/9617988 to your computer and use it in GitHub Desktop.
Save lega911/9617988 to your computer and use it in GitHub Desktop.
import threading
import time
from contextlib import contextmanager
@contextmanager
def timeit(exception=Exception):
start = time.time()
yield
print(time.time() - start)
def lf(lst):
with timeit():
for i in range(1000):
lst.append(i)
def f1():
lst = []
lf(lst)
lf(lst)
def f2():
lst = []
lf(lst)
t = threading.Thread(target=lf, args=(lst,))
t.start()
t.join()
def main():
f1()
f2()
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment