Skip to content

Commit

Permalink
add benchmark_lsjj
Browse files Browse the repository at this point in the history
  • Loading branch information
0382 committed Oct 6, 2023
1 parent 87438bf commit df2e500
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions benchmark/benchmark_lsjj.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using CGcoefficient
using BenchmarkTools

function calculate_lsjj(test_range::AbstractArray)
sum = 0.0
for l1 in test_range
for l2 in test_range
for (dj1, dj2) in [(2l1-1, 2l2-1), (2l1-1, 2l2+1), (2l1+1, 2l2-1), (2l1+1, 2l2+1)]
for L in abs(l1-l2):(l1+l2)
for (S, J) in [(0, L), (1, L-1), (1, L), (1, L+1)]
sum += flsjj(l1, l2, dj1, dj2, L, S, J)
end
end
end
end
end
return sum
end

function calculate_norm9j(test_range::AbstractArray)
sum = 0.0
for l1 in test_range
for l2 in test_range
for (dj1, dj2) in [(2l1-1, 2l2-1), (2l1-1, 2l2+1), (2l1+1, 2l2-1), (2l1+1, 2l2+1)]
for L in abs(l1-l2):(l1+l2)
for (S, J) in [(0, L), (1, L-1), (1, L), (1, L+1)]
sum += fnorm9j(2l1, 1, dj1, 2l2, 1, dj2, 2L, 2S, 2J)
end
end
end
end
end
return sum
end

test_range = 0:10

t1 = @belapsed calculate_lsjj(test_range)
t2 = @belapsed calculate_norm9j(test_range)

println("diff = ", calculate_lsjj(test_range) - calculate_norm9j(test_range))
println("lsjj time = $(t1)s")
println("norm9j time = $(t2)s")

0 comments on commit df2e500

Please sign in to comment.