Benchmarks

The benchmarks below were run on Julia 1.8.0.

Default example

X = [40 30 20 10; 35 50 100 75; 30 80 70 120; 20 30 40 50]
u = [150, 300, 400, 150]
v = [200, 300, 400, 100]
@benchmark ipf(X, [u, v])
BenchmarkTools.Trial: 10000 samples with 1 evaluation.
 Range (min … max):   92.402 μs …   5.046 ms  ┊ GC (min … max): 0.00% … 96.06%
 Time  (median):     105.502 μs               ┊ GC (median):    0.00%
 Time  (mean ± σ):   116.689 μs ± 142.089 μs  ┊ GC (mean ± σ):  3.65% ±  3.02%

    ██▄▃▂▁                                                       
  ▂███████▇▆▅▅▄▄▄▄▃▃▃▃▂▂▂▂▂▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁ ▂
  92.4 μs          Histogram: frequency by time          216 μs <

 Memory estimate: 46.30 KiB, allocs estimate: 849.

Large contingency table

X = reshape(repeat(1:16, 625), 100, 100)
Y = reshape(repeat(1:5, 2000), 100, 100) + X
m = ArrayMargins(Y)
@benchmark ipf(X, m)
BenchmarkTools.Trial: 7547 samples with 1 evaluation.
 Range (min … max):  520.607 μs …   5.526 ms  ┊ GC (min … max): 0.00% …  0.00%
 Time  (median):     568.407 μs               ┊ GC (median):    0.00%
 Time  (mean ± σ):   657.324 μs ± 299.604 μs  ┊ GC (mean ± σ):  7.85% ± 12.96%

  ▆█▆▅▅▄▄▄▃▂▂▁                                                  ▂
  █████████████▇▆▄▄▄▄▅▄▃▄▁▃▃▃▃▁▁▃▁▄▁▁▁▃▁▁▃▁▆▄▅▃▃▁▄▆▇███▇▇▇█▇▇▆▅ █
  521 μs        Histogram: log(frequency) by time       2.05 ms <

 Memory estimate: 1.73 MiB, allocs estimate: 1063.

Six-dimensional contingency table

X = reshape(repeat(1:12, 100), 6, 4, 2, 5, 5)
Y = reshape(repeat(1:5, 240), 6, 4, 2, 5, 5) + X
m = ArrayMargins(Y)
@benchmark ipf(X, m)
BenchmarkTools.Trial: 4304 samples with 1 evaluation.
 Range (min … max):  902.115 μs …   8.569 ms  ┊ GC (min … max): 0.00% … 0.00%
 Time  (median):       1.071 ms               ┊ GC (median):    0.00%
 Time  (mean ± σ):     1.157 ms ± 423.901 μs  ┊ GC (mean ± σ):  3.25% ± 7.72%

   ▄█▁                                                           
  ▂████▆▅▄▃▂▂▂▂▂▂▂▂▂▂▂▁▁▂▁▁▁▁▂▂▂▁▂▁▂▁▂▁▁▁▁▁▁▁▁▂▁▁▁▁▁▁▁▁▁▁▁▁▁▂▂▂ ▂
  902 μs           Histogram: frequency by time         4.26 ms <

 Memory estimate: 503.12 KiB, allocs estimate: 3022.