Skip to content

Commit 7f2a61a

Browse files
Add warm-up functions
1 parent 7d590d3 commit 7f2a61a

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

test/downstream/alloccheck.jl

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ using SciMLOperators: IdentityOperator,
44
ScaledOperator,
55
AddedOperator
66

7+
function apply_op!(H, w, v, u, p, t)
8+
H(w, v, u, p, t)
9+
return nothing
10+
end
11+
12+
test_apply_noalloc(H, w, v, u, p, t) = @test (@allocations apply_op!(H, w, v, u, p, t)) == 0
13+
714
@testset "Allocations Check" begin
815
Random.seed!(0)
916
N = 8
@@ -17,13 +24,7 @@ using SciMLOperators: IdentityOperator,
1724
t = 0
1825
op = AddedOperator(A, B)
1926

20-
function apply_op!(H, w, v, u, p, t)
21-
H(w, v, u, p, t)
22-
return nothing
23-
end
24-
25-
test_apply_noalloc(H, w, v, u, p, t) = @test (@allocations apply_op!(H, w, v, u, p, t)) == 0
26-
27+
apply_op!(op, w, v, u, p, t) # Warm up
2728
test_apply_noalloc(op, w, v, u, p, t)
2829

2930
for T in (Float32, Float64, ComplexF32, ComplexF64)
@@ -53,6 +54,8 @@ using SciMLOperators: IdentityOperator,
5354
p == 0.1,)
5455
t = 0.1
5556

57+
apply_op!(H_sparse, w, v, u, p, t) # Warm up
58+
apply_op!(H_dense, w, v, u, p, t) # Warm up
5659
test_apply_noalloc(H_sparse, w, v, u, p, t)
5760
test_apply_noalloc(H_dense, w, v, u, p, t)
5861
end

0 commit comments

Comments
 (0)