Benchmarks

The benchmarks below were run on Julia version 1.11.5.

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 per sample.
 Range (min … max):  54.121 μs …  12.064 ms  ┊ GC (min … max): 0.00% … 99.01%
 Time  (median):     57.718 μs               ┊ GC (median):    0.00%
 Time  (mean ± σ):   62.745 μs ± 153.441 μs  ┊ GC (mean ± σ):  3.99% ±  1.70%

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

 Memory estimate: 38.00 KiB, allocs estimate: 813.

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 per sample.
 Range (min … max):  142.347 μs …   5.731 ms  ┊ GC (min … max): 0.00% … 14.17%
 Time  (median):     152.916 μs               ┊ GC (median):    0.00%
 Time  (mean ± σ):   168.698 μs ± 120.020 μs  ┊ GC (mean ± σ):  5.53% ±  9.00%

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

 Memory estimate: 274.31 KiB, allocs estimate: 888.

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: 10000 samples with 1 evaluation per sample.
 Range (min … max):  425.546 μs …   9.064 ms  ┊ GC (min … max): 0.00% … 94.05%
 Time  (median):     442.598 μs               ┊ GC (median):    0.00%
 Time  (mean ± σ):   454.199 μs ± 194.932 μs  ┊ GC (mean ± σ):  1.78% ±  3.93%

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

 Memory estimate: 108.06 KiB, allocs estimate: 1726.