Loosing performance with `Threads.@threads` for loop

Thanks for the tests! I fear something must be severely wrong wither with the server or my julia environment:

julia> test1(1)
3.523 s (20467 allocations: 571.43 MiB)
julia> test1(2)
12.826 s (10615 allocations: 566.19 MiB)
julia> test1(5)
19.033 s (4687 allocations: 553.89 MiB)
julia> test1(10)
11.294 s (2490 allocations: 534.52 MiB)
julia> test1(40)
9.206 s (889 allocations: 496.15 MiB)
julia> test2()
694.097 ms (502 allocations: 572.43 MiB)

Global scope cannot be the problem: I used @goerch 's examples for this and in my production code, where I observed these problems, everything is also nicely packed into functions.