Benchmarking questions

Note also that your benchmarks are incorrect since Julia optimizes your loops away because your functions don’t return anything, and so independently by the magnitude of a and b it takes a small amount of ns:


julia> @benchmark test_1(1000000000,10000000000)
BenchmarkTools.Trial: 10000 samples with 1000 evaluations.
 Range (min … max):  4.700 ns … 73.700 ns  ┊ GC (min … max): 0.00% … 0.00%
 Time  (median):     5.700 ns              ┊ GC (median):    0.00%
 Time  (mean ± σ):   5.514 ns ±  1.185 ns  ┊ GC (mean ± σ):  0.00% ± 0.00%

  ▅ █       ▁ ▂  ▂ ▃  ▃ ▄  ▆ █  ▇ ▅  ▄ ▃  ▁                  ▂
  █▁█▁▁▅▁█▁▁█▁█▁▁█▁█▁▁█▁█▁▁█▁█▁▁█▁█▁▁█▁█▁▁█▁█▁▁▇▁▇▁▁▆▁▇▁▁█▁█ █
  4.7 ns       Histogram: log(frequency) by time        7 ns <

 Memory estimate: 0 bytes, allocs estimate: 0.
1 Like