Created
March 17, 2014 17:32
-
-
Save lega911/9604181 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import timeit | |
import threading | |
def lf(lst): | |
for i in range(10000): | |
lst.append(i) | |
def f1(): | |
lst = [] | |
lf(lst) | |
lf(lst) | |
def f2(): | |
t = threading.Thread(target=f1) | |
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