You could create a, say, @maybethreads
macro which depending on a global switch does the same thing as @threads
or nothing, respectively. See @assert alternatives? - #14 by WschW for a similar example. You might also want to check out https://github.com/KristofferC/TimerOutputs.jl/blob/master/README.md#overhead.