using QuadGK
a = 1.0
f = x -> sin(a*x)/(a*x)
@time quadgk(f, -1e8, 0, 1e8)
@time quadgk(f, -1e8, 0, 1e8)
@time quadgk(f, -1e8, 0, 1e8)
3.615248 seconds (102.46 M allocations: 1.682 GiB, 6.61% gc time, 31.70% compilation time) 2.071347 seconds (99.33 M allocations: 1.502 GiB, 1.69% gc time) 2.042287 seconds (99.33 M allocations: 1.502 GiB, 1.54% gc time)
(3.143368529490813, 0.1453072535439617)
dump(f)
#1 (function of type var"#1#2")
a = 1.0
g = let a = a; x -> sin(a*x)/(a*x) end
@time quadgk(g, -1e8, 0, 1e8)
@time quadgk(g, -1e8, 0, 1e8)
@time quadgk(g, -1e8, 0, 1e8)
0.825576 seconds (7.15 M allocations: 165.328 MiB, 4.23% gc time, 25.27% compilation time) 0.752624 seconds (6.67 M allocations: 139.071 MiB, 16.41% gc time) 0.561307 seconds (6.67 M allocations: 131.071 MiB, 1.08% gc time)
(3.143368529490813, 0.1453072535439617)
dump(g)
#3 (function of type var"#3#4"{Float64}) a: Float64 1.0
function F(a = 1.0)
quadgk(x -> sin(a*x)/(a*x), -1e8, 0, 1e8)
end
@time F()
@time F()
@time F()
0.760919 seconds (6.68 M allocations: 139.744 MiB, 3.36% gc time, 23.61% compilation time) 0.684874 seconds (6.67 M allocations: 139.071 MiB, 15.97% gc time) 0.560951 seconds (6.67 M allocations: 131.071 MiB, 1.20% gc time)
(3.143368529490813, 0.1453072535439617)