Skip to content

Commit 2d1ea1e

Browse files
committed
tests: add benchmarking test for cat picking
1 parent d89c0e9 commit 2d1ea1e

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

tests/test_benchmark_category_axis.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,39 @@ def run(h, data):
3434
h.fill(data)
3535

3636
benchmark(run, h, tuple(values) if dtype is tuple else values.astype(dtype))
37+
38+
39+
@pytest.mark.benchmark(group="Pick")
40+
def test_pick_only(benchmark):
41+
42+
h = bh.Histogram(
43+
bh.axis.StrCategory([str(i) for i in range(32)]),
44+
bh.axis.StrCategory([str(i) for i in range(32)]),
45+
bh.axis.StrCategory([str(i) for i in range(32)]),
46+
bh.axis.Regular(32, 0, 320),
47+
)
48+
49+
h[...] = 1.0
50+
51+
def run(h):
52+
return h[bh.loc("13"), bh.loc("13"), bh.loc("13"), :].view()
53+
54+
benchmark(run, h)
55+
56+
57+
@pytest.mark.benchmark(group="Pick")
58+
def test_pick_and_slice(benchmark):
59+
60+
h = bh.Histogram(
61+
bh.axis.StrCategory([str(i) for i in range(32)]),
62+
bh.axis.StrCategory([str(i) for i in range(32)]),
63+
bh.axis.StrCategory([str(i) for i in range(32)]),
64+
bh.axis.Regular(32, 0, 320),
65+
)
66+
67+
h[...] = 1.0
68+
69+
def run(h):
70+
return h[3:29, bh.loc("13"), bh.loc("13"), :].view()
71+
72+
benchmark(run, h)

0 commit comments

Comments
 (0)