Skip to content

Instantly share code, notes, and snippets.

@ranocha
Last active January 27, 2021 08:29
Show Gist options
  • Save ranocha/26d624948741d5cd530cf55cd3d2d737 to your computer and use it in GitHub Desktop.
Save ranocha/26d624948741d5cd530cf55cd3d2d737 to your computer and use it in GitHub Desktop.
using Plots
#=
results obtained from running
for polydeg in 1:7
@show polydeg
tabulate_benchmarks(benchmark_euler, levels=0:8, polydeg=polydeg)
end
with https://github.com/jlchan/ESDG.jl/blob/refactor/Trixi_comparison/benchmark_JC/benchmark_euler2D.jl
=#
results_jesse = """
polydeg = 1
#Elements | Runtime in seconds
1 | 5.21e-06
4 | 8.22e-06
16 | 2.01e-05
64 | 7.11e-05
256 | 2.60e-04
1024 | 1.06e-03
4096 | 4.11e-03
16384 | 1.98e-02
65536 | 8.10e-02
polydeg = 2
#Elements | Runtime in seconds
1 | 1.30e-05
4 | 1.88e-05
16 | 4.26e-05
64 | 1.40e-04
256 | 5.32e-04
1024 | 2.09e-03
4096 | 8.29e-03
16384 | 3.40e-02
65536 | 1.42e-01
polydeg = 3
#Elements | Runtime in seconds
1 | 3.79e-05
4 | 5.06e-05
16 | 1.02e-04
64 | 2.86e-04
256 | 1.08e-03
1024 | 4.01e-03
4096 | 1.60e-02
16384 | 6.59e-02
65536 | 2.83e-01
polydeg = 4
#Elements | Runtime in seconds
1 | 8.60e-05
4 | 1.08e-04
16 | 1.93e-04
64 | 5.20e-04
256 | 1.84e-03
1024 | 6.94e-03
4096 | 2.97e-02
16384 | 1.20e-01
65536 | 4.85e-01
polydeg = 5
#Elements | Runtime in seconds
1 | 1.67e-04
4 | 2.05e-04
16 | 3.36e-04
64 | 9.18e-04
256 | 3.08e-03
1024 | 1.18e-02
4096 | 4.71e-02
16384 | 1.92e-01
65536 | 7.73e-01
polydeg = 6
#Elements | Runtime in seconds
1 | 3.08e-04
4 | 3.67e-04
16 | 5.74e-04
64 | 1.43e-03
256 | 4.72e-03
1024 | 1.79e-02
4096 | 7.10e-02
16384 | 2.88e-01
65536 | 1.15e+00
polydeg = 7
#Elements | Runtime in seconds
1 | 5.07e-04
4 | 5.88e-04
16 | 8.93e-04
64 | 2.11e-03
256 | 6.84e-03
1024 | 2.58e-02
4096 | 1.03e-01
16384 | 4.17e-01
65536 | 2.10e+00
polydeg = 15
#Elements | Runtime in seconds
1 | 1.14e-02
4 | 1.14e-02
16 | 1.41e-02
64 | 2.23e-02
256 | 5.74e-02
1024 | 2.00e-01
4096 | 7.85e-01
16384 | 3.30e+00
65536 | 1.30e+01
"""
#=
results obtained from running
for polydeg in 1:7
@show polydeg
tabulate_benchmarks(benchmark_euler, levels=0:8, polydeg=polydeg)
end
with https://gist.github.com/ranocha/c24405efce2a2c94af9573208bf2e980
=#
results_trixi = """
polydeg = 1
#Elements | Runtime in seconds
1 | 1.69e-05
4 | 1.82e-05
16 | 2.23e-05
64 | 3.83e-05
256 | 1.00e-04
1024 | 3.57e-04
4096 | 1.50e-03
16384 | 5.97e-03
65536 | 2.87e-02
polydeg = 2
#Elements | Runtime in seconds
1 | 1.85e-05
4 | 2.07e-05
16 | 3.06e-05
64 | 7.05e-05
256 | 2.28e-04
1024 | 9.28e-04
4096 | 3.60e-03
16384 | 1.43e-02
65536 | 6.43e-02
polydeg = 3
#Elements | Runtime in seconds
1 | 1.93e-05
4 | 2.47e-05
16 | 4.56e-05
64 | 1.29e-04
256 | 4.70e-04
1024 | 1.91e-03
4096 | 7.45e-03
16384 | 3.05e-02
65536 | 1.31e-01
polydeg = 4
#Elements | Runtime in seconds
1 | 2.14e-05
4 | 3.11e-05
16 | 7.11e-05
64 | 2.26e-04
256 | 8.70e-04
1024 | 3.51e-03
4096 | 1.35e-02
16384 | 5.70e-02
65536 | 2.36e-01
polydeg = 5
#Elements | Runtime in seconds
1 | 2.38e-05
4 | 4.08e-05
16 | 1.06e-04
64 | 3.70e-04
256 | 1.46e-03
1024 | 5.84e-03
4096 | 2.26e-02
16384 | 9.58e-02
65536 | 3.93e-01
polydeg = 6
#Elements | Runtime in seconds
1 | 2.75e-05
4 | 5.34e-05
16 | 1.57e-04
64 | 5.70e-04
256 | 2.27e-03
1024 | 9.05e-03
4096 | 3.55e-02
16384 | 1.49e-01
65536 | 6.07e-01
polydeg = 7
#Elements | Runtime in seconds
1 | 3.23e-05
4 | 6.99e-05
16 | 2.27e-04
64 | 8.66e-04
256 | 3.36e-03
1024 | 1.34e-02
4096 | 5.35e-02
16384 | 2.22e-01
65536 | 8.97e-01
polydeg = 15
#Elements | Runtime in seconds
1 | 1.25e-04
4 | 4.37e-04
16 | 1.68e-03
64 | 6.58e-03
256 | 2.60e-02
1024 | 1.05e-01
4096 | 4.28e-01
16384 | 1.70e+00
65536 | 6.85e+00
"""
function parse_results(result_string)
polydegs = Int[]
elements = Dict{Int, Vector{Int}}()
runtimes = Dict{Int, Vector{Float64}}()
for line in eachline(IOBuffer(result_string))
startswith(line, '#') && continue
polydeg_match = match(r"polydeg = (\d+)", line)
if polydeg_match !== nothing
polydeg = parse(Int, polydeg_match.captures[1])
push!(polydegs, polydeg)
elements[polydeg] = Int[]
runtimes[polydeg] = Float64[]
continue
end
# assume everything follows the convention...
line_element, line_runtime = split(line, "|")
push!(elements[polydegs[end]], parse(Int, line_element))
push!(runtimes[polydegs[end]], parse(Float64, line_runtime))
end
return polydegs, elements, runtimes
end
# parse and plot results
polydegs, elements, runtimes_trixi = parse_results(results_trixi)
polydegs_jesse, elements_jesse, runtimes_jesse = parse_results(results_jesse)
@assert polydegs == polydegs_jesse
@assert elements == elements_jesse
plot(xguide="#DOFs per scalar (= #elements * (polydeg + 1)^2)", yguide="Runtime (seconds)", title="Benchmarking Jesse (dashed) vs. Trixi (solid)")
colors = ["#E69F00", "#56B4E9", "#009E73", "#0072B2", "#D55E00", "#CC79A7", "#F0E442", "gray"]
for (polydeg,color) in zip(polydegs, colors)
dof_scaling = (polydeg+1)^2
linewidth = 2
plot!(elements[polydeg] * dof_scaling, runtimes_trixi[polydeg]; label="polydeg = $polydeg", linestyle=:solid, color, linewidth)
plot!(elements[polydeg] * dof_scaling, runtimes_jesse[polydeg]; label="", linestyle=:dash, color, linewidth)
end
plot!(xscale=:log10, yscale=:log10, legend=:bottomright, dpi=120)
# savefig("~/benchmark_jesse_trixi_absolute.png")
plot(xguide="#DOFs per scalar (= #elements * (polydeg + 1)^2)", yguide="Runtime relative to Trixi", title="Benchmarking Jesse vs. Trixi")
for (polydeg,color) in zip(polydegs, colors)
dof_scaling = (polydeg+1)^2
linewidth = 2
plot!(elements[polydeg] * dof_scaling, runtimes_jesse[polydeg] ./ runtimes_trixi[polydeg]; label="polydeg = $polydeg", linestyle=:solid, color, linewidth)
end
plot!(xscale=:log10, legend=:topright, ylim=(0,15), dpi=120)
# savefig("~/benchmark_jesse_trixi_relative.png")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment