-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Closed
Labels
mathsMathematical functionsMathematical functionsperformanceMust go fasterMust go fasterregressionRegression in behavior compared to a previous versionRegression in behavior compared to a previous versionregression 1.12Regression in the 1.12 releaseRegression in the 1.12 release
Description
Arising from #54512.
MWE:
function norm_me_base(V)
return sqrt(V[1]^2 + V[2]^2 + V[3]^2)
end
@fastmath function norm_me_fast(V)
return sqrt(V[1]^2 + V[2]^2 + V[3]^2)
end
function norm_me_base_ntimes(V, n::Int)
y = 0.0
for i = 1:n
y += norm_me_base(V)
end
return y
end
function norm_me_fast_ntimes(V, n::Int)
y = 0.0
for i = 1:n
y += norm_me_fast(V)
end
return y
end
using BenchmarkTools
using StaticArrays
function benchmark_that()
v = SVector{3}(10.567, 5.4, 2.28)
@btime norm_me_base(v)
# 1.11 2.800 ns (0 allocations: 0 bytes)
# 1.12 2.800 ns (0 allocations: 0 bytes)
@btime norm_me_fast(v)
# 1.11 2.900 ns (0 allocations: 0 bytes)
# 1.12 82.102 ns (0 allocations: 0 bytes)
@btime norm_me_base_ntimes(v, 1000)
# 1.11 850.667 ns (0 allocations: 0 bytes)
# 1.12 800.000 ns (0 allocations: 0 bytes)
@btime norm_me_fast_ntimes(v, 1000)
# 1.11 857.143 ns (0 allocations: 0 bytes)
# 1.12 79.100 μs (0 allocations: 0 bytes)
end| Function | Julia 1.11 | Julia 1.12 |
|---|---|---|
norm_me_base(v) |
2.800 ns (0 allocations: 0 bytes) | 2.800 ns (0 allocations: 0 bytes) |
norm_me_fast(v) |
2.900 ns (0 allocations: 0 bytes) | 82.102 ns (0 allocations: 0 bytes) |
norm_me_base_ntimes(v, 1000) |
850.667 ns (0 allocations: 0 bytes) | 800.000 ns (0 allocations: 0 bytes) |
norm_me_fast_ntimes(v, 1000) |
857.143 ns (0 allocations: 0 bytes) | 79.100 μs (0 allocations: 0 bytes) |
Metadata
Metadata
Assignees
Labels
mathsMathematical functionsMathematical functionsperformanceMust go fasterMust go fasterregressionRegression in behavior compared to a previous versionRegression in behavior compared to a previous versionregression 1.12Regression in the 1.12 releaseRegression in the 1.12 release