The problem is CSV.write
functions. They take much longer time than actual data generation and affected by IO
. By removing all lines after the loop (starting from df1 = DataFrame(V_id)
up to return) I get the following numbers:
@btime run_singlethread(3, 10000)
# 1.847 ms (30006 allocations: 3.59 MiB)
@btime multithread_run(3, 10000)
# 814.549 μs (40051 allocations: 4.05 MiB)