Skip to content

Commit e175efe

Browse files
committed
numpy: add some more windowing benches
1 parent 1daffd3 commit e175efe

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ BENCHES := ""
22
BENCHFLAGS :=
33

44
python-bench: numpy/*.py
5-
pytest $(BENCHFLAGS) $(BENCHES)
5+
pytest --ignore=taco $(BENCHFLAGS) $(BENCHES)
66

77
taco-bench: taco/build/taco-bench
88
ifeq ($(BENCHES),"")

numpy/windowing.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ def test_add_sparse_window(benchmark):
99
def bench():
1010
x = matrix[1:(dim-1), 1:(dim-1)]
1111
res = x + x
12+
# Sanity check that this has a similar runtime as taco.
13+
# res = matrix + matrix
1214
benchmark.pedantic(bench, iterations=10)
1315

1416
def test_add_multiple_sparse_windows(benchmark):
@@ -19,3 +21,21 @@ def test_add_multiple_sparse_windows(benchmark):
1921
def bench():
2022
res = matrix1[1:(dim-1), 1:(dim-1)] + matrix2[1:(dim-1), 1:(dim-1)] + matrix1[0:(dim-2), 0:(dim-2)]
2123
benchmark.pedantic(bench, iterations=10)
24+
25+
def test_add_sparse_strided_window(benchmark):
26+
dim = 10000
27+
matrix = random(dim, dim, format="csr")
28+
def bench():
29+
x = matrix[1:(dim-1):2, 1:(dim-1):2]
30+
res = x + x
31+
benchmark.pedantic(bench, iterations=10)
32+
33+
def test_add_sparse_index_set(benchmark):
34+
dim = 10000
35+
indexes = [i * 2 for i in range(0, dim//2)]
36+
matrix = random(dim, dim, format="csr")
37+
def bench():
38+
x = matrix[:, indexes]
39+
res = x + x
40+
benchmark.pedantic(bench, iterations=10)
41+

0 commit comments

Comments
 (0)