Skip to content

Commit 5e9b4ab

Browse files
authored
add nested commutator benchmark (#26)
1 parent 352f5c2 commit 5e9b4ab

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

benchmarks/commutator.jl

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
function nested_commutator(term, n)
2+
if n == 0
3+
return term
4+
else
5+
return commutator(term, nested_commutator(term, n - 1))
6+
end
7+
end
8+
9+
function benchmark_commutator!(SUITE)
10+
h = FockSpace(:cavity)
11+
@qnumbers a::Destroy(h)
12+
13+
term = a'*a
14+
n=5
15+
16+
SUITE["Micro Benchmarks"]["Nested commutator"] = @benchmarkable nested_commutator(
17+
$term, $n
18+
) seconds = 20
19+
return nothing
20+
end

benchmarks/runbenchmarks.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ const SUITE = BenchmarkGroup()
55

66
include("SW.jl")
77
include("numeric_conversion.jl")
8+
include("commutator.jl")
89

910
# benchmark_numeric_conversion!(SUITE) # need a more complex example (this one is too fast)
1011
benchmark_Schrieffer_Wolf!(SUITE)
12+
benchmark_commutator!(SUITE)
1113

1214
BenchmarkTools.tune!(SUITE)
1315
results = BenchmarkTools.run(SUITE; verbose=true)

0 commit comments

Comments
 (0)