Added speedup project code.
This commit is contained in:
35
content/posts/python-speedup/code/test.py
Normal file
35
content/posts/python-speedup/code/test.py
Normal file
@ -0,0 +1,35 @@
|
||||
from concurrent import interpreters
|
||||
from libspeedup import my_stat_counter
|
||||
|
||||
|
||||
def calc():
|
||||
my_stat_counter(2)
|
||||
my_stat_counter(2)
|
||||
a = my_stat_counter(2)
|
||||
print(a)
|
||||
|
||||
|
||||
def main():
|
||||
my_stat_counter(1)
|
||||
my_stat_counter(1)
|
||||
int1 = interpreters.create()
|
||||
int2 = interpreters.create()
|
||||
int3 = interpreters.create()
|
||||
|
||||
t1 = int1.call_in_thread(calc)
|
||||
t2 = int2.call_in_thread(calc)
|
||||
t3 = int3.call_in_thread(calc)
|
||||
|
||||
t1.join()
|
||||
t2.join()
|
||||
t3.join()
|
||||
|
||||
int1.close()
|
||||
int2.close()
|
||||
int3.close()
|
||||
|
||||
print(my_stat_counter(1))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user