I want to know how expensive the floating number division is, compared to the multiplication. Using BenchmarkTools
, I found they are the same.
julia> @benchmark $(Ref(a))[] * $(Ref(b))[]
BenchmarkTools.Trial: 10000 samples with 1000 evaluations.
Range (min … max): 1.372 ns … 15.229 ns ┊ GC (min … max): 0.00% … 0.00%
Time (median): 1.546 ns ┊ GC (median): 0.00%
Time (mean ± σ): 1.556 ns ± 0.315 ns ┊ GC (mean ± σ): 0.00% ± 0.00%
▇ █
▃▃▂▁▁▁▁▂▄▃▁▁▁▁▁▂█▆▂▂▁▁▁▁▃█▃▂▁▁▁▁▁▃██▂▁▁▁▁▁▁██▆▃▂▂▂▂▁▁▂▄▄▄▃ ▃
1.37 ns Histogram: frequency by time 1.66 ns <
Memory estimate: 0 bytes, allocs estimate: 0.
julia> @benchmark $(Ref(a))[] / $(Ref(b))[]
BenchmarkTools.Trial: 10000 samples with 1000 evaluations.
Range (min … max): 1.413 ns … 32.495 ns ┊ GC (min … max): 0.00% … 0.00%
Time (median): 1.545 ns ┊ GC (median): 0.00%
Time (mean ± σ): 1.550 ns ± 0.470 ns ┊ GC (mean ± σ): 0.00% ± 0.00%
▅▃ ▆ ▂▂ ▆█
▃▃▂▁▁▁▁▁▁▄██▄▂▂▂▁▁▁▂▇██▃▂▁▁▁▁▁▂▅██▃▁▂▁▁▁▁▁▄███▄▂▂▂▁▁▁▁▂▂▂▂ ▃
1.41 ns Histogram: frequency by time 1.65 ns <
Memory estimate: 0 bytes, allocs estimate: 0.
where a
and b
are Float64
.
Given that the division should be several times slower than the multiplication, how do I interpret this result?