Skip to content

Commit 898dd21

Browse files
Use @test_allocations from TrixiTest.jl (#113)
* use at-test_allocations from TrixiTest.jl * format * add comments back
1 parent e258cc3 commit 898dd21

File tree

9 files changed

+126
-756
lines changed

9 files changed

+126
-756
lines changed

test/test_dgmulti_1d.jl

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,7 @@ isdir(outdir) && rm(outdir, recursive = true)
3333
])
3434
# Ensure that we do not have excessive memory allocations
3535
# (e.g., from type instabilities)
36-
let
37-
t = sol.t[end]
38-
u_ode = sol.u[end]
39-
du_ode = similar(u_ode)
40-
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
41-
end
36+
@test_allocations(Trixi.rhs!, semi, sol, 1000)
4237
end
4338
end # DGMulti1D
4439

test/test_dgmulti_2d.jl

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,7 @@ isdir(outdir) && rm(outdir, recursive = true)
3333
])
3434
# Ensure that we do not have excessive memory allocations
3535
# (e.g., from type instabilities)
36-
let
37-
t = sol.t[end]
38-
u_ode = sol.u[end]
39-
du_ode = similar(u_ode)
40-
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
41-
end
36+
@test_allocations(Trixi.rhs!, semi, sol, 1000)
4237
end
4338

4439
@trixi_testset "elixir_shallowwater_source_terms.jl (Tri, SBP)" begin
@@ -59,12 +54,7 @@ end
5954
])
6055
# Ensure that we do not have excessive memory allocations
6156
# (e.g., from type instabilities)
62-
let
63-
t = sol.t[end]
64-
u_ode = sol.u[end]
65-
du_ode = similar(u_ode)
66-
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
67-
end
57+
@test_allocations(Trixi.rhs!, semi, sol, 1000)
6858
end
6959

7060
@trixi_testset "elixir_shallowwater_source_terms.jl (Tri, Polynomial)" begin
@@ -87,12 +77,7 @@ end
8777
])
8878
# Ensure that we do not have excessive memory allocations
8979
# (e.g., from type instabilities)
90-
let
91-
t = sol.t[end]
92-
u_ode = sol.u[end]
93-
du_ode = similar(u_ode)
94-
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
95-
end
80+
@test_allocations(Trixi.rhs!, semi, sol, 1000)
9681
end
9782

9883
@trixi_testset "elixir_shallowwater_source_terms.jl (Quad, Polynomial)" begin
@@ -117,12 +102,7 @@ end
117102
])
118103
# Ensure that we do not have excessive memory allocations
119104
# (e.g., from type instabilities)
120-
let
121-
t = sol.t[end]
122-
u_ode = sol.u[end]
123-
du_ode = similar(u_ode)
124-
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
125-
end
105+
@test_allocations(Trixi.rhs!, semi, sol, 1000)
126106
end
127107
end # DGMulti2D
128108

test/test_p4est_2d.jl

Lines changed: 9 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,7 @@ isdir(outdir) && rm(outdir, recursive = true)
3434
tspan=(0.0, 0.1))
3535
# Ensure that we do not have excessive memory allocations
3636
# (e.g., from type instabilities)
37-
let
38-
t = sol.t[end]
39-
u_ode = sol.u[end]
40-
du_ode = similar(u_ode)
41-
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
42-
end
37+
@test_allocations(Trixi.rhs!, semi, sol, 1000)
4338
end
4439

4540
@trixi_testset "elixir_shallowwater_well_balanced_nonconforming.jl" begin
@@ -61,12 +56,7 @@ isdir(outdir) && rm(outdir, recursive = true)
6156
atol=1e-10)
6257
# Ensure that we do not have excessive memory allocations
6358
# (e.g., from type instabilities)
64-
let
65-
t = sol.t[end]
66-
u_ode = sol.u[end]
67-
du_ode = similar(u_ode)
68-
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
69-
end
59+
@test_allocations(Trixi.rhs!, semi, sol, 1000)
7060
end
7161

7262
@trixi_testset "elixir_shallowwater_perturbation_amr.jl" begin
@@ -87,12 +77,7 @@ isdir(outdir) && rm(outdir, recursive = true)
8777
tspan=(0.0, 0.025))
8878
# Ensure that we do not have excessive memory allocations
8979
# (e.g., from type instabilities)
90-
let
91-
t = sol.t[end]
92-
u_ode = sol.u[end]
93-
du_ode = similar(u_ode)
94-
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
95-
end
80+
@test_allocations(Trixi.rhs!, semi, sol, 1000)
9681
end
9782

9883
@trixi_testset "elixir_shallowwater_well_balanced_wet_dry_nonconforming.jl" begin
@@ -114,12 +99,7 @@ isdir(outdir) && rm(outdir, recursive = true)
11499
atol=1e-10)
115100
# Ensure that we do not have excessive memory allocations
116101
# (e.g., from type instabilities)
117-
let
118-
t = sol.t[end]
119-
u_ode = sol.u[end]
120-
du_ode = similar(u_ode)
121-
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
122-
end
102+
@test_allocations(Trixi.rhs!, semi, sol, 1000)
123103
end
124104

125105
# Note, these values may change as the functionality of well-balanced mortars
@@ -143,12 +123,7 @@ isdir(outdir) && rm(outdir, recursive = true)
143123
tspan=(0.0, 0.025))
144124
# Ensure that we do not have excessive memory allocations
145125
# (e.g., from type instabilities)
146-
let
147-
t = sol.t[end]
148-
u_ode = sol.u[end]
149-
du_ode = similar(u_ode)
150-
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
151-
end
126+
@test_allocations(Trixi.rhs!, semi, sol, 1000)
152127
end
153128
end # SWE
154129

@@ -170,12 +145,7 @@ end # SWE
170145
atol=1e-10)
171146
# Ensure that we do not have excessive memory allocations
172147
# (e.g., from type instabilities)
173-
let
174-
t = sol.t[end]
175-
u_ode = sol.u[end]
176-
du_ode = similar(u_ode)
177-
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
178-
end
148+
@test_allocations(Trixi.rhs!, semi, sol, 1000)
179149
end
180150

181151
# Note, these values may change as the functionality of well-balanced mortars
@@ -198,12 +168,7 @@ end # SWE
198168

199169
# Ensure that we do not have excessive memory allocations
200170
# (e.g., from type instabilities)
201-
let
202-
t = sol.t[end]
203-
u_ode = sol.u[end]
204-
du_ode = similar(u_ode)
205-
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
206-
end
171+
@test_allocations(Trixi.rhs!, semi, sol, 1000)
207172
end
208173

209174
# Note, complex example that uses TrixiBottomTopography.jl to approximate
@@ -228,12 +193,7 @@ end # SWE
228193

229194
# Ensure that we do not have excessive memory allocations
230195
# (e.g., from type instabilities)
231-
let
232-
t = sol.t[end]
233-
u_ode = sol.u[end]
234-
du_ode = similar(u_ode)
235-
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
236-
end
196+
@test_allocations(Trixi.rhs!, semi, sol, 1000)
237197
end
238198

239199
@trixi_testset "elixir_shallowwater_multilayer_three_mound_dam_break_amr.jl" begin
@@ -254,12 +214,7 @@ end # SWE
254214

255215
# Ensure that we do not have excessive memory allocations
256216
# (e.g., from type instabilities)
257-
let
258-
t = sol.t[end]
259-
u_ode = sol.u[end]
260-
du_ode = similar(u_ode)
261-
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
262-
end
217+
@test_allocations(Trixi.rhs!, semi, sol, 1000)
263218
end
264219
end # MLSWE
265220
end # P4estMesh2D

test/test_structured_2d.jl

Lines changed: 5 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,7 @@ isdir(outdir) && rm(outdir, recursive = true)
3434
tspan=(0.0, 0.05))
3535
# Ensure that we do not have excessive memory allocations
3636
# (e.g., from type instabilities)
37-
let
38-
t = sol.t[end]
39-
u_ode = sol.u[end]
40-
du_ode = similar(u_ode)
41-
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
42-
end
37+
@test_allocations(Trixi.rhs!, semi, sol, 1000)
4338
end
4439

4540
@trixi_testset "elixir_shallowwater_well_balanced.jl" begin
@@ -60,12 +55,7 @@ isdir(outdir) && rm(outdir, recursive = true)
6055
tspan=(0.0, 0.25))
6156
# Ensure that we do not have excessive memory allocations
6257
# (e.g., from type instabilities)
63-
let
64-
t = sol.t[end]
65-
u_ode = sol.u[end]
66-
du_ode = similar(u_ode)
67-
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
68-
end
58+
@test_allocations(Trixi.rhs!, semi, sol, 1000)
6959
end
7060

7161
@trixi_testset "elixir_shallowwater_well_balanced_wet_dry.jl" begin
@@ -87,12 +77,7 @@ isdir(outdir) && rm(outdir, recursive = true)
8777
atol=1e-12)
8878
# Ensure that we do not have excessive memory allocations
8979
# (e.g., from type instabilities)
90-
let
91-
t = sol.t[end]
92-
u_ode = sol.u[end]
93-
du_ode = similar(u_ode)
94-
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
95-
end
80+
@test_allocations(Trixi.rhs!, semi, sol, 1000)
9681
end
9782

9883
@trixi_testset "elixir_shallowwater_conical_island.jl" begin
@@ -113,12 +98,7 @@ isdir(outdir) && rm(outdir, recursive = true)
11398
tspan=(0.0, 0.025))
11499
# Ensure that we do not have excessive memory allocations
115100
# (e.g., from type instabilities)
116-
let
117-
t = sol.t[end]
118-
u_ode = sol.u[end]
119-
du_ode = similar(u_ode)
120-
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
121-
end
101+
@test_allocations(Trixi.rhs!, semi, sol, 1000)
122102
end
123103

124104
@trixi_testset "elixir_shallowwater_parabolic_bowl.jl" begin
@@ -139,12 +119,7 @@ isdir(outdir) && rm(outdir, recursive = true)
139119
tspan=(0.0, 0.025), cells_per_dimension=(40, 40))
140120
# Ensure that we do not have excessive memory allocations
141121
# (e.g., from type instabilities)
142-
let
143-
t = sol.t[end]
144-
u_ode = sol.u[end]
145-
du_ode = similar(u_ode)
146-
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
147-
end
122+
@test_allocations(Trixi.rhs!, semi, sol, 1000)
148123
end
149124
end # SWE
150125
end # StructuredMesh2D

test/test_t8code_2d.jl

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,7 @@ isdir(outdir) && rm(outdir, recursive = true)
3333
tspan=(0.0, 0.1))
3434
# Ensure that we do not have excessive memory allocations
3535
# (e.g., from type instabilities)
36-
let
37-
t = sol.t[end]
38-
u_ode = sol.u[end]
39-
du_ode = similar(u_ode)
40-
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
41-
end
36+
@test_allocations(Trixi.rhs!, semi, sol, 1000)
4237
end
4338
end # T8codeMesh2D
4439
end # module

0 commit comments

Comments
 (0)