Skip to content

Instantly share code, notes, and snippets.

@lega911
Created March 17, 2014 17:41
Show Gist options
  • Save lega911/9604373 to your computer and use it in GitHub Desktop.
Save lega911/9604373 to your computer and use it in GitHub Desktop.
import timeit
import threading
lst = []
def lf():
del lst[:]
for i in range(10000):
lst.append(i)
def f1():
lf()
lf()
def f2():
t = threading.Thread(target=lf)
t.start()
#t.join()
t = threading.Thread(target=lf)
t.start()
t.join()
def main():
t1 = timeit.Timer('f1()', 'from __main__ import f1')
t2 = timeit.Timer('f2()', 'from __main__ import f2')
for t in t1, t2:
print(t.repeat(3, 100))
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment