Skip to content

Commit e2744bb

Browse files
committed
numpy: start using n rounds to get aggregate stats about benches
1 parent cc2c9a0 commit e2744bb

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

numpy/conftest.py

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import pytest
2+
@pytest.fixture
3+
def tacoBench(benchmark):
4+
def f(func):
5+
# Take statistics based on 10 rounds.
6+
benchmark.pedantic(func, rounds=10)
7+
return f

numpy/windowing.py

+10-11
Original file line numberDiff line numberDiff line change
@@ -2,46 +2,45 @@
22
from scipy.sparse import random
33
import pytest
44

5-
def test_add_window(benchmark):
5+
def test_add_window(tacoBench):
66
dim = 10000
77
matrix = random(dim, dim, format="csr").todense()
88
def bench():
99
x = matrix[1:(dim-1), 1:(dim-1)]
1010
res = x + x
11-
benchmark.pedantic(bench, iterations=10)
11+
tacoBench(bench)
1212

1313
@pytest.mark.parametrize("dim", [5000, 10000, 20000])
14-
def test_add_sparse_window(benchmark, dim):
14+
def test_add_sparse_window(tacoBench, dim):
1515
matrix = random(dim, dim, format="csr")
1616
def bench():
1717
x = matrix[1:(dim-1), 1:(dim-1)]
1818
res = x + x
1919
# Sanity check that this has a similar runtime as taco.
2020
# res = matrix + matrix
21-
benchmark.pedantic(bench, iterations=10)
21+
tacoBench(bench)
2222

2323
@pytest.mark.parametrize("dim", [5000, 10000, 20000])
24-
def test_add_multiple_sparse_windows(benchmark, dim):
24+
def test_add_multiple_sparse_windows(tacoBench, dim):
2525
matrix1 = random(dim, dim, format="csr")
2626
matrix2 = random(dim, dim, format="csr")
2727
def bench():
2828
res = matrix1[1:(dim-1), 1:(dim-1)] + matrix2[1:(dim-1), 1:(dim-1)] + matrix1[0:(dim-2), 0:(dim-2)]
29-
benchmark.pedantic(bench, iterations=10)
29+
tacoBench(bench)
3030

3131
@pytest.mark.parametrize("dim", [5000, 10000, 20000])
32-
def test_add_sparse_strided_window(benchmark, dim):
32+
def test_add_sparse_strided_window(tacoBench, dim):
3333
matrix = random(dim, dim, format="csr")
3434
def bench():
3535
x = matrix[1:(dim-1):2, 1:(dim-1):2]
3636
res = x + x
37-
benchmark.pedantic(bench, iterations=10)
37+
tacoBench(bench)
3838

3939
@pytest.mark.parametrize("dim", [5000, 10000, 20000])
40-
def test_add_sparse_index_set(benchmark, dim):
40+
def test_add_sparse_index_set(tacoBench, dim):
4141
indexes = [i * 2 for i in range(0, dim//2)]
4242
matrix = random(dim, dim, format="csr")
4343
def bench():
4444
x = matrix[:, indexes]
4545
res = x + x
46-
benchmark.pedantic(bench, iterations=10)
47-
46+
tacoBench(bench)

0 commit comments

Comments
 (0)