Skip to content

Commit

Permalink
explicitly benchmark reli*
Browse files Browse the repository at this point in the history
  • Loading branch information
Expander committed Sep 16, 2023
1 parent f716314 commit 41f975f
Showing 1 changed file with 62 additions and 46 deletions.
108 changes: 62 additions & 46 deletions test/Bench.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,15 @@ import PolyLog
n = 10_000_000
z_min = -5
z_max = 5
cmpl_data = (z_max - z_min)*rand(ComplexF64, n) + z_min*(1.0 + 1.0im)*ones(n)
real_data = map(real, cmpl_data)
c64_data = (z_max - z_min)*rand(ComplexF64, n) + z_min*(1.0 + 1.0im)*ones(n)
f64_data = map(real, c64_data)
f32_data = map(Float32, f64_data)

time_reli2(data) = @time map(PolyLog.reli2, data)
time_reli3(data) = @time map(PolyLog.reli3, data)
time_reli4(data) = @time map(PolyLog.reli4, data)
time_reli5(data) = @time map(PolyLog.reli5, data)
time_reli6(data) = @time map(PolyLog.reli6, data)

time_li2(data) = @time map(PolyLog.li2, data)
time_li3(data) = @time map(PolyLog.li3, data)
Expand All @@ -14,82 +21,91 @@ time_li6(data) = @time map(PolyLog.li6, data)

println("Benchmarking li2::Float64")

map(PolyLog.li2, real_data) # trigger compilation
time_li2(real_data)
time_li2(real_data)
time_li2(real_data)
map(PolyLog.reli2, f64_data) # trigger compilation
time_reli2(f64_data)
time_reli2(f64_data)
time_reli2(f64_data)

println("Benchmarking li2::Float32")

map(PolyLog.reli2, f32_data) # trigger compilation
time_reli2(f32_data)
time_reli2(f32_data)
time_reli2(f32_data)

println("Benchmarking li2::ComplexF64")

map(PolyLog.li2, cmpl_data) # trigger compilation
time_li2(cmpl_data)
time_li2(cmpl_data)
time_li2(cmpl_data)
map(PolyLog.li2, c64_data) # trigger compilation
time_li2(c64_data)
time_li2(c64_data)
time_li2(c64_data)

println("Benchmarking li3::Float64")

map(PolyLog.li3, real_data) # trigger compilation
time_li3(real_data)
time_li3(real_data)
time_li3(real_data)
map(PolyLog.reli3, f64_data) # trigger compilation
time_reli3(f64_data)
time_reli3(f64_data)
time_reli3(f64_data)

println("Benchmarking li3::ComplexF64")

map(PolyLog.li3, cmpl_data) # trigger compilation
time_li3(cmpl_data)
time_li3(cmpl_data)
time_li3(cmpl_data)
map(PolyLog.li3, c64_data) # trigger compilation
time_li3(c64_data)
time_li3(c64_data)
time_li3(c64_data)

println("Benchmarking li4::Float64")
println("Benchmarking reli4::Float64")

map(PolyLog.li4, real_data) # trigger compilation
time_li4(real_data)
time_li4(real_data)
time_li4(real_data)
map(PolyLog.reli4, f64_data) # trigger compilation
time_reli4(f64_data)
time_reli4(f64_data)
time_reli4(f64_data)

println("Benchmarking li4::ComplexF64")

map(PolyLog.li4, cmpl_data) # trigger compilation
time_li4(cmpl_data)
time_li4(cmpl_data)
time_li4(cmpl_data)
map(PolyLog.li4, c64_data) # trigger compilation
time_li4(c64_data)
time_li4(c64_data)
time_li4(c64_data)

println("Benchmarking li5::ComplexF64")

map(PolyLog.li5, cmpl_data) # trigger compilation
time_li5(cmpl_data)
time_li5(cmpl_data)
time_li5(cmpl_data)
map(PolyLog.li5, c64_data) # trigger compilation
time_li5(c64_data)
time_li5(c64_data)
time_li5(c64_data)

println("Benchmarking li6::ComplexF64")

map(PolyLog.li6, cmpl_data) # trigger compilation
time_li6(cmpl_data)
time_li6(cmpl_data)
time_li6(cmpl_data)
map(PolyLog.li6, c64_data) # trigger compilation
time_li6(c64_data)
time_li6(c64_data)
time_li6(c64_data)

println("Benchmarking li::Float64")

time_li(k, data) = @time map(x -> PolyLog.li(k, x), data)
time_reli(k, data) = @time map(x -> PolyLog.reli(k, x), data)

n = 1_000_000
cmpl_data = (z_max - z_min)*rand(ComplexF64, n) + z_min*(1.0 + 1.0im)*ones(n)
real_data = map(real, cmpl_data)
c64_data = (z_max - z_min)*rand(ComplexF64, n) + z_min*(1.0 + 1.0im)*ones(n)
f64_data = map(real, c64_data)

for k in vcat(collect(-10:2:10), [100, 1000, 1000_000, -100, -1000, -1000_000])
println("Benchmarking li($(k),x)::Float64")
map(x -> PolyLog.li(k, x), real_data) # trigger compilation
time_li(k, real_data) # trigger compilation
time_li(k, real_data)
time_li(k, real_data)
map(x -> PolyLog.reli(k, x), f64_data) # trigger compilation
time_reli(k, f64_data) # trigger compilation
time_reli(k, f64_data)
time_reli(k, f64_data)
end

println("Benchmarking li::ComplexF64")

time_li(k, data) = @time map(x -> PolyLog.li(k, x), data)

for k in vcat(collect(-10:2:10), [100, 1000, 1000_000, -100, -1000, -1000_000])
println("Benchmarking li($(k),x)::ComplexF64")
map(x -> PolyLog.li(k, x), cmpl_data) # trigger compilation
time_li(k, cmpl_data) # trigger compilation
time_li(k, cmpl_data)
time_li(k, cmpl_data)
map(x -> PolyLog.li(k, x), c64_data) # trigger compilation
time_li(k, c64_data) # trigger compilation
time_li(k, c64_data)
time_li(k, c64_data)
end

0 comments on commit 41f975f

Please sign in to comment.