Skip to content

Commit

Permalink
Merge pull request #47 from Ericgig/add_Dia
Browse files Browse the repository at this point in the history
Add dia data layer to benchmarks
  • Loading branch information
Ericgig authored Oct 30, 2023
2 parents 7ed6ef8 + 4e223b8 commit 7067a06
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
22 changes: 12 additions & 10 deletions qutip_benchmark/benchmarks/bench_linear_algebra.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@

# Available datatypes (using qutip_dense and qutip_csr to avoid confusion
# with density parameters)
@pytest.fixture(params=["numpy", "scipy_csr", "qutip_dense", "qutip_csr"])
@pytest.fixture(
params=["numpy", "scipy_csr", "qutip_dense", "qutip_csr", "qutip_dia"]
)
def dtype(request):
return request.param

Expand Down Expand Up @@ -41,6 +43,8 @@ def left_oper(size, density, dtype):
return res.to("dense")
if dtype == "qutip_csr":
return res.to("csr")
if dtype == "qutip_dia":
return res.to("dia")
raise Exception("The specified dtype is invalid")


Expand All @@ -63,6 +67,8 @@ def right_oper(size, density, dtype):
return res.to("dense")
if dtype == "qutip_csr":
return res.to("csr")
if dtype == "qutip_dia":
return res.to("dia")
raise Exception("The specified dtype is invalid")


Expand All @@ -81,6 +87,8 @@ def right_ket(size, density, dtype):
return res.to("dense")
if dtype == "qutip_csr":
return res.to("csr")
if dtype == "qutip_dia":
return res.to("dia")
raise Exception("The specified dtype is invalid")


Expand All @@ -97,26 +105,20 @@ def add(left, right):
return left + right

# Run benchmark
result = benchmark(add, left_oper, right_oper)

return result
benchmark(add, left_oper, right_oper)


@pytest.mark.nightly
def bench_matmul_oper_oper(benchmark, left_oper, right_oper):
benchmark.group = "math:matmul:op-times-op"

# Benchmark operations
result = benchmark(matmul, left_oper, right_oper)

return result
benchmark(matmul, left_oper, right_oper)


@pytest.mark.nightly
def bench_matmul_oper_ket(benchmark, left_oper, right_ket):
benchmark.group = "math:matmul:op-times-ket"

# Run benchmark
result = benchmark(matmul, left_oper, right_ket)

return result
benchmark(matmul, left_oper, right_ket)
4 changes: 1 addition & 3 deletions qutip_benchmark/benchmarks/bench_qobjevo.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,4 @@ def matmul(left, right):
def bench_matmul_QobjEvo_ket(benchmark, left_QobjEvo, right_ket):
benchmark.group = "math:matmul:qobjevo-op-times-ket"

result = benchmark(matmul, left_QobjEvo, right_ket)

return result
benchmark(matmul, left_QobjEvo, right_ket)

0 comments on commit 7067a06

Please sign in to comment.