Skip to content

Instantly share code, notes, and snippets.


zhen yuan zhenyuan992

View GitHub Profile
zhenyuan992 /
Last active December 5, 2022 06:55
benchmarks python's build-in multiprocessing. uses all the threads available in the system.
import multiprocessing as mp
import timeit
print(f"Number of threads: {threads}")
vlist=range(15000) # takes about 5 seconds to run serially
def f(v):
return sum([v_ for v_ in range(v)])
start_pool = timeit.default_timer()
with mp.Pool(threads) as p: