Skip to content

Commit 7728f33

Browse files
committed
numpy: parametrize striding benchmark over stride width
1 parent 7a84b23 commit 7728f33

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

numpy/windowing.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,12 @@ def bench():
5656

5757
@pytest.mark.parametrize("dim", [5000, 10000, 20000])
5858
@pytest.mark.parametrize("format", ['csr', 'csc'])
59-
def bench_add_sparse_strided_window(tacoBench, dim, format):
60-
loader = ScipySparseTensorLoader(format)
59+
@pytest.mark.parametrize("strideWidth", [2, 4, 8])
60+
def bench_add_sparse_strided_window(tacoBench, dim, format, strideWidth):
61+
loader = RandomScipySparseTensorLoader(format)
6162
matrix = loader.random((dim, dim), 0.01)
6263
def bench():
63-
x = matrix[1:(dim-1):4, 1:(dim-1):4]
64+
x = matrix[0:dim:strideWidth, 0:dim:strideWidth]
6465
res = x + x
6566
tacoBench(bench)
6667

@@ -76,11 +77,12 @@ def bench():
7677
tacoBench(bench)
7778

7879
@pytest.mark.parametrize("dim", [5000, 10000, 20000])
79-
def bench_add_pydata_sparse_strided_window(tacoBench, dim):
80+
@pytest.mark.parametrize("strideWidth", [2, 4, 8])
81+
def bench_add_pydata_sparse_strided_window(tacoBench, dim, strideWidth):
8082
loader = RandomPydataSparseTensorLoader()
8183
matrix = loader.random((dim, dim), 0.01)
8284
def bench():
83-
x = matrix[1:(dim-1):4, 1:(dim-1):4]
85+
x = matrix[0:dim:strideWidth, 0:dim:strideWidth]
8486
res = x + x
8587
tacoBench(bench)
8688

0 commit comments

Comments
 (0)