@@ -13,27 +13,63 @@ def compute_earth_mover_dist(first, second):
1313 return d [row_ind , col_ind ].sum ()
1414
1515
16- def setup_data ():
16+ def setup_data (rows , cols ):
1717 """Generates random data for benchmarking."""
1818 rng = np .random .default_rng ()
19- data1 = rng .random ((50 , 50 ) )
20- data2 = rng .random ((50 , 50 ) )
19+ data1 = rng .random ((rows , cols ), dtype = np . float64 )
20+ data2 = rng .random ((rows , cols ), dtype = np . float64 )
2121 return data1 , data2
2222
2323
24- def test_rust_emd_benchmark (benchmark ):
25- """Benchmark the Rust-backed EMD calculation."""
26- data1 , data2 = setup_data ()
24+ def test_rust_emd_benchmark_small (benchmark ):
25+ """Benchmark the Rust-backed EMD calculation on small data ."""
26+ data1 , data2 = setup_data (17 , 11 )
2727 benchmark (compute_earth_movers_distance_2d , data1 , data2 , False )
2828
2929
30- def test_rust_emd_par_benchmark (benchmark ):
31- """Benchmark the Rust-backed EMD calculation."""
32- data1 , data2 = setup_data ()
30+ def test_rust_emd_benchmark_medium (benchmark ):
31+ """Benchmark the Rust-backed EMD calculation on medium data."""
32+ data1 , data2 = setup_data (50 , 50 )
33+ benchmark (compute_earth_movers_distance_2d , data1 , data2 , False )
34+
35+
36+ def test_rust_emd_benchmark_large (benchmark ):
37+ """Benchmark the Rust-backed EMD calculation on large data."""
38+ data1 , data2 = setup_data (100 , 100 )
39+ benchmark (compute_earth_movers_distance_2d , data1 , data2 , False )
40+
41+
42+ def test_rust_emd_par_benchmark_small (benchmark ):
43+ """Benchmark the Rust-backed EMD calculation with parallel processing on small data."""
44+ data1 , data2 = setup_data (17 , 11 )
45+ benchmark (compute_earth_movers_distance_2d , data1 , data2 , True )
46+
47+
48+ def test_rust_emd_par_benchmark_medium (benchmark ):
49+ """Benchmark the Rust-backed EMD calculation with parallel processing on medium data."""
50+ data1 , data2 = setup_data (50 , 50 )
3351 benchmark (compute_earth_movers_distance_2d , data1 , data2 , True )
3452
3553
36- def test_numpy_emd_benchmark (benchmark ):
37- """Benchmark the numpy/scipy EMD calculation."""
38- data1 , data2 = setup_data ()
54+ def test_rust_emd_par_benchmark_large (benchmark ):
55+ """Benchmark the Rust-backed EMD calculation with parallel processing on large data."""
56+ data1 , data2 = setup_data (100 , 100 )
57+ benchmark (compute_earth_movers_distance_2d , data1 , data2 , True )
58+
59+
60+ def test_numpy_emd_benchmark_small (benchmark ):
61+ """Benchmark the numpy/scipy EMD calculation on small data."""
62+ data1 , data2 = setup_data (17 , 11 )
63+ benchmark (compute_earth_mover_dist , data1 , data2 )
64+
65+
66+ def test_numpy_emd_benchmark_medium (benchmark ):
67+ """Benchmark the numpy/scipy EMD calculation on medium data."""
68+ data1 , data2 = setup_data (50 , 50 )
69+ benchmark (compute_earth_mover_dist , data1 , data2 )
70+
71+
72+ def test_numpy_emd_benchmark_large (benchmark ):
73+ """Benchmark the numpy/scipy EMD calculation on large data."""
74+ data1 , data2 = setup_data (100 , 100 )
3975 benchmark (compute_earth_mover_dist , data1 , data2 )
0 commit comments