I was profiling timing differences between using sin
, sind
, and I noticed some interesting results.
julia> using BenchmarkTools
julia> sin(10);
julia> sind(10);
julia> const ° = π/180;
julia> x = 1.234;
julia> @btime sin($x)
6.289 ns (0 allocations: 0 bytes)
0.9438182093746337
julia> @btime sind($x)
10.923 ns (0 allocations: 0 bytes)
0.02153569796186157
julia> @btime sin($x * $°)
4.280 ns (0 allocations: 0 bytes)
0.021535697961861566
Why is the last one faster than the first one? It’s the same function. From what I understand, it should be slower if anything, since there’s an additional multiplication involved.