|
2 | 2 | from scipy.sparse import random
|
3 | 3 | import pytest
|
4 | 4 |
|
5 |
| -def test_add_sparse_window(benchmark): |
| 5 | +def test_add_window(benchmark): |
6 | 6 | dim = 10000
|
7 |
| - matrix = random(dim, dim, format="csr") |
| 7 | + matrix = random(dim, dim, format="csr").todense() |
| 8 | + def bench(): |
| 9 | + x = matrix[1:(dim-1), 1:(dim-1)] |
| 10 | + res = x + x |
| 11 | + benchmark.pedantic(bench, iterations=10) |
8 | 12 |
|
| 13 | +@pytest.mark.parametrize("dim", [5000, 10000, 20000]) |
| 14 | +def test_add_sparse_window(benchmark, dim): |
| 15 | + matrix = random(dim, dim, format="csr") |
9 | 16 | def bench():
|
10 | 17 | x = matrix[1:(dim-1), 1:(dim-1)]
|
11 | 18 | res = x + x
|
12 | 19 | # Sanity check that this has a similar runtime as taco.
|
13 | 20 | # res = matrix + matrix
|
14 | 21 | benchmark.pedantic(bench, iterations=10)
|
15 | 22 |
|
16 |
| -def test_add_multiple_sparse_windows(benchmark): |
17 |
| - dim = 10000 |
| 23 | +@pytest.mark.parametrize("dim", [5000, 10000, 20000]) |
| 24 | +def test_add_multiple_sparse_windows(benchmark, dim): |
18 | 25 | matrix1 = random(dim, dim, format="csr")
|
19 | 26 | matrix2 = random(dim, dim, format="csr")
|
20 |
| - |
21 | 27 | def bench():
|
22 | 28 | res = matrix1[1:(dim-1), 1:(dim-1)] + matrix2[1:(dim-1), 1:(dim-1)] + matrix1[0:(dim-2), 0:(dim-2)]
|
23 | 29 | benchmark.pedantic(bench, iterations=10)
|
24 | 30 |
|
25 |
| -def test_add_sparse_strided_window(benchmark): |
26 |
| - dim = 10000 |
| 31 | +@pytest.mark.parametrize("dim", [5000, 10000, 20000]) |
| 32 | +def test_add_sparse_strided_window(benchmark, dim): |
27 | 33 | matrix = random(dim, dim, format="csr")
|
28 | 34 | def bench():
|
29 | 35 | x = matrix[1:(dim-1):2, 1:(dim-1):2]
|
30 | 36 | res = x + x
|
31 | 37 | benchmark.pedantic(bench, iterations=10)
|
32 | 38 |
|
33 |
| -def test_add_sparse_index_set(benchmark): |
34 |
| - dim = 10000 |
| 39 | +@pytest.mark.parametrize("dim", [5000, 10000, 20000]) |
| 40 | +def test_add_sparse_index_set(benchmark, dim): |
35 | 41 | indexes = [i * 2 for i in range(0, dim//2)]
|
36 | 42 | matrix = random(dim, dim, format="csr")
|
37 | 43 | def bench():
|
|
0 commit comments