View benchmark_python_multiprocessing.py
This file contains 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 multiprocessing as mp | |
import timeit | |
threads=mp.cpu_count() | |
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: |