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):  86.901 μs …   4.897 ms  ┊ GC (min … max): 0.00% … 96.74%
 Time  (median):     88.602 μs               ┊ GC (median):    0.00%
 Time  (mean ± σ):   95.081 μs ± 148.533 μs  ┊ GC (mean ± σ):  4.88% ±  3.07%

  ▁▅▇█▇▆▄▃▂▂▁▁   ▁▁▁ ▁▁                                        ▂
  █████████████▇██████████▇▇▇████████▇▇▇▇█▇▇▆▇▇▇▆▆▆▆▇▆▆▆▆▆▆▆▆▆ █
  86.9 μs       Histogram: log(frequency) by time       112 μs <

 Memory estimate: 48.17 KiB, allocs estimate: 916.

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: 10000 samples with 1 evaluation.
 Range (min … max):  292.805 μs …   2.233 ms  ┊ GC (min … max): 0.00% … 48.44%
 Time  (median):     385.005 μs               ┊ GC (median):    0.00%
 Time  (mean ± σ):   434.824 μs ± 216.803 μs  ┊ GC (mean ± σ):  8.65% ± 13.21%

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

 Memory estimate: 1.74 MiB, allocs estimate: 1143.

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: 6147 samples with 1 evaluation.
 Range (min … max):  761.614 μs …   4.217 ms  ┊ GC (min … max): 0.00% … 79.46%
 Time  (median):     773.614 μs               ┊ GC (median):    0.00%
 Time  (mean ± σ):   810.598 μs ± 319.915 μs  ┊ GC (mean ± σ):  4.09% ±  8.16%

  █▁                                                            ▁
  ██▁▁▃▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▃▅ █
  762 μs        Histogram: log(frequency) by time       3.59 ms <

 Memory estimate: 506.22 KiB, allocs estimate: 3156.