Skip to content

Commit 803e447

Browse files
authored
TST: test matrix.sum costing time (#1085)
* Parametrize sum performance test with multiple sizes Replaces the skipped performance test with a parameterized test for matrix sizes 500, 1000, and 2000 to allow benchmarking across different input sizes. * TST: test `matrix.sum` costing time use `np.ndarray.sum` instead of `np.sum` * Remove 2000 datasize case 40min is still running * Remove 1000 datasize case 7min is still running * Remove 500 datasize case 7min is still running
1 parent c3a2666 commit 803e447

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

tests/test_matrix_variable.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -216,15 +216,15 @@ def test_matrix_sum_argument():
216216
assert (m.getVal(x) == np.full((2, 3), 4)).all().all()
217217
assert (m.getVal(y) == np.full((2, 4), 3)).all().all()
218218

219-
@pytest.mark.skip(reason="Performance test")
220-
def test_sum_performance():
221-
n = 1000
219+
220+
@pytest.mark.parametrize("n", [50, 100, 200])
221+
def test_sum_performance(n):
222222
model = Model()
223223
x = model.addMatrixVar((n, n))
224224

225-
# Original sum via `np.sum`
225+
# Original sum via `np.ndarray.sum`, `np.sum` will call subclass method
226226
start_orig = time()
227-
np.sum(x)
227+
np.ndarray.sum(x)
228228
end_orig = time()
229229

230230
# Optimized sum via `quicksum`

0 commit comments

Comments
 (0)