Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
trixi-framework
GitHub Repository: trixi-framework/Trixi.jl
Path: blob/main/benchmark/benchmark_ec.jl
2055 views
1
using Printf, BenchmarkTools, Trixi
2
3
function run_benchmarks(benchmark_run; levels = 0:5, polydeg = 3)
4
runtimes = zeros(length(levels))
5
for (idx, initial_refinement_level) in enumerate(levels)
6
result = benchmark_run(; initial_refinement_level, polydeg)
7
display(result)
8
runtimes[idx] = result |> median |> time # in nanoseconds
9
end
10
return (; levels, runtimes, polydeg)
11
end
12
13
function tabulate_benchmarks(args...; kwargs...)
14
result = run_benchmarks(args...; kwargs...)
15
println("#Elements | Runtime in seconds")
16
for (level, runtime) in zip(result.levels, result.runtimes)
17
@printf("%9d | %.2e\n", 4^level, 1.0e-9*runtime)
18
end
19
for (level, runtime) in zip(result.levels, result.runtimes)
20
@printf("%.16e\n", 1.0e-9*runtime)
21
end
22
end
23
24
function benchmark_euler(; initial_refinement_level = 1, polydeg = 3)
25
γ = 1.4
26
equations = CompressibleEulerEquations2D(γ)
27
28
surface_flux = flux_ranocha
29
volume_flux = flux_ranocha
30
solver = DGSEM(polydeg, surface_flux, VolumeIntegralFluxDifferencing(volume_flux))
31
32
coordinates_min = (-2.0, -2.0)
33
coordinates_max = (2.0, 2.0)
34
mesh = TreeMesh(coordinates_min, coordinates_max,
35
initial_refinement_level = initial_refinement_level,
36
n_cells_max = 100_000)
37
38
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_weak_blast_wave,
39
solver)
40
41
t0 = 0.0
42
u0 = compute_coefficients(t0, semi)
43
du = similar(u0)
44
45
@benchmark Trixi.rhs!($du, $u0, $semi, $t0)
46
end
47
48
# versioninfo(verbose=true)
49
@show Threads.nthreads()
50
tabulate_benchmarks(benchmark_euler, levels = 0:8)
51
52