You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This avoids overhead when threading is disabled, Example benchmark:
```
using BenchmarkTools, Base.Threads
function func(val)
local sum = 0
for idx in 1:100
sum += idx.^val
end
return sum
end
function func_threaded(val)
local sum = 0
@threads for idx in 1:100
sum += idx.^val
end
return sum
end
@show@benchmark func(2.0)
@show@benchmark func_threaded(2.0)
```
Before change:
```
@benchmark(func(2.0)) = Trial(94.464 ns)
@benchmark(func_threaded(2.0)) = Trial(8.228 μs)
```
After change:
```
@benchmark(func(2.0)) = Trial(93.766 ns)
@benchmark(func_threaded(2.0)) = Trial(93.765 ns)
```
0 commit comments