From 9fcbb04a903cea36bdd9a2c43824f9420976e0ea Mon Sep 17 00:00:00 2001 From: Daniel_Doehring Date: Tue, 19 Mar 2024 23:49:27 +0100 Subject: [PATCH] alloc tests --- test/test_p4est_2d.jl | 19 ++++++++++++++++++- test/test_parabolic_2d.jl | 8 ++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/test/test_p4est_2d.jl b/test/test_p4est_2d.jl index bf65a2490e8..f5ccf2ffd38 100644 --- a/test/test_p4est_2d.jl +++ b/test/test_p4est_2d.jl @@ -546,7 +546,15 @@ end 0.09772818519679008, 0.4311796171737692, ], tspan=(0.0, 0.001)) - + # Ensure that we do not have excessive memory allocations + # (e.g., from type instabilities) + let + t = sol.t[end] + u_ode = sol.u[end] + du_ode = similar(u_ode) + @test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000 + end + u_ode = copy(sol.u[end]) du_ode = zero(u_ode) # Just a placeholder in this case @@ -578,6 +586,15 @@ end adapt_initial_condition=false, adapt_initial_condition_only_refine=false) + # Ensure that we do not have excessive memory allocations + # (e.g., from type instabilities) + let + t = sol.t[end] + u_ode = sol.u[end] + du_ode = similar(u_ode) + @test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000 + end + u_ode = copy(sol.u[end]) du_ode = zero(u_ode) # Just a placeholder in this case diff --git a/test/test_parabolic_2d.jl b/test/test_parabolic_2d.jl index 3f4f7183a4e..9ba09a9268e 100644 --- a/test/test_parabolic_2d.jl +++ b/test/test_parabolic_2d.jl @@ -702,6 +702,14 @@ end 0.9077214424040279, 5.666071182328691], tspan=(0.0, 0.001), initial_refinement_level=0) + # Ensure that we do not have excessive memory allocations + # (e.g., from type instabilities) + let + t = sol.t[end] + u_ode = sol.u[end] + du_ode = similar(u_ode) + @test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000 + end end end