Skip to content

Commit

Permalink
Add wrapper benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
Saelyos committed Oct 20, 2023
1 parent 2bdb258 commit bffc5ea
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions pint/testsuite/benchmarks/test_20_quantity.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,39 @@ def test_op2(benchmark, setup, keys, op):
_, data = setup
key1, key2 = keys
benchmark(op, data[key1], data[key2])


@pytest.mark.parametrize("key", ALL_VALUES_Q)
def test_wrapper(benchmark, setup, key):
ureg, data = setup
value, unit = key.split("_")

@ureg.wraps(None, (unit,))
def f(a):
pass

benchmark(f, data[key])


@pytest.mark.parametrize("key", ALL_VALUES_Q)
def test_wrapper_nonstrict(benchmark, setup, key):
ureg, data = setup
value, unit = key.split("_")

@ureg.wraps(None, (unit,), strict=False)
def f(a):
pass

benchmark(f, data[value])


@pytest.mark.parametrize("key", ALL_VALUES_Q)
def test_wrapper_ret(benchmark, setup, key):
ureg, data = setup
value, unit = key.split("_")

@ureg.wraps(unit, (unit,))
def f(a):
return a

benchmark(f, data[key])

0 comments on commit bffc5ea

Please sign in to comment.