diff --git a/test/blockmap.jl b/test/blockmap.jl index 36c016f6..62fdf20f 100644 --- a/test/blockmap.jl +++ b/test/blockmap.jl @@ -290,12 +290,9 @@ using LinearMaps: FiveArg @test mul!(copy(v), LinearMap(transform(L)), u, α, β) ≈ transform(M)*u*α + v*β if transform != adjoint transL = transform(L) - alloc = @allocated similar(v) - if L == L2 && α != false - @test_broken (@allocated mul!(v, transL, u, α, β)) <= alloc - else - @test (@allocated mul!(v, transL, u, α, β)) <= alloc - end + similar(v) + alloc = @allocations similar(v) + @test (@allocations mul!(v, transL, u, α, β)) <= alloc broken=(L == L2 && α != false) end end end diff --git a/test/functionmap.jl b/test/functionmap.jl index 16b3c5de..95ea1ab1 100644 --- a/test/functionmap.jl +++ b/test/functionmap.jl @@ -87,8 +87,8 @@ using Test, LinearMaps, LinearAlgebra @test mul!(copy(v), LinearMap(transform(CS!)), u, α, β) ≈ transform(M)*u*α + v*β if transform != transpose transCS! = transform(CS!) - alloc = @allocated similar(v) - @test (@allocated mul!(v, transCS!, u, α, β)) <= alloc + alloc = @allocations similar(v) + @test (@allocations mul!(v, transCS!, u, α, β)) <= alloc + 1 end end end diff --git a/test/linearcombination.jl b/test/linearcombination.jl index 19a1c5c7..1422882f 100644 --- a/test/linearcombination.jl +++ b/test/linearcombination.jl @@ -12,19 +12,19 @@ using LinearMaps: FiveArg, LinearMapTuple, LinearMapVector, FunctionMap mul!(u, CS!, v) @test (@allocated mul!(u, CS!, v)) == 0 n = 10 - alloc = @allocated similar(v) + alloc = (@allocations similar(v)) + 1 Loop = @inferred CS + CS + CS @test Loop * v ≈ 3cumsum(v) @test (CS + CR + CS) * v ≈ 3cumsum(v) - @test (@allocated Loop * v) <= 3alloc + @test (@allocations Loop * v) <= 3alloc Loop = @inferred CS + CS; Loop * v - @test (@allocated Loop * v) <= 2alloc + @test (@allocations Loop * v) <= 2alloc Lmix = @inferred CS + CS + CS!; Lmix * v - @test (@allocated Lmix * v) <= 3alloc + @test (@allocations Lmix * v) <= 3alloc Lmix = @inferred CS + CS + CS!; Lmix * v - @test (@allocated Lmix * v) <= 3alloc + @test (@allocations Lmix * v) <= 3alloc Lmix = @inferred CS! + (CS + CS); Lmix * v - @test (@allocated Lmix * v) <= 3alloc + @test (@allocations Lmix * v) <= 3alloc L = @inferred sum(ntuple(_ -> CS!, n)) @test (@inferred sum(L.maps::LinearMapTuple)) == L Lv = @inferred LinearMaps.LinearCombination{ComplexF64}(fill(CS!, n)) @@ -60,11 +60,11 @@ using LinearMaps: FiveArg, LinearMapTuple, LinearMapVector, FunctionMap @test occursin("10×10 $LinearMaps.LinearCombination{$(eltype(L))}", sprint((t, s) -> show(t, "text/plain", s), L+CS!)) @test mul!(u, L, v) ≈ n * cumsum(v) @test mul!(u, Lv, v) ≈ n * cumsum(v) - alloc = @allocated similar(u) + alloc = (@allocations similar(u)) + 1 mul!(u, L, v, 2, 2) - @test (@allocated mul!(u, L, v, 2, 2)) <= alloc + @test (@allocations mul!(u, L, v, 2, 2)) <= alloc mul!(u, Lv, v, 2, 2) - @test (@allocated mul!(u, Lv, v, 2, 2)) <= alloc + @test (@allocations mul!(u, Lv, v, 2, 2)) <= alloc for α in (false, true, rand(ComplexF64)), β in (false, true, rand(ComplexF64)) for transform in (identity, adjoint, transpose) @test mul!(copy(u), transform(L), v, α, β) ≈ transform(M)*v*α + u*β diff --git a/test/scaledmap.jl b/test/scaledmap.jl index 8a35f27e..6316ce8f 100644 --- a/test/scaledmap.jl +++ b/test/scaledmap.jl @@ -101,11 +101,10 @@ using Test, LinearMaps, LinearAlgebra λ = 4.2 B0 = @inferred λ * A0 B1 = @inferred λ * A1 - for (A, alloc) in ((A0, 1), (A1, 0), (B0, 1), (B1, 0), (A0', 3), (A1', 0), (B0', 3), (B1', 0)) + for (A, alloc) in ((A0, 3), (A1, 0), (B0, 3), (B1, 0), (A0', 9), (A1', 0), (B0', 9), (B1', 0)) x = rand(N) y = similar(x) - allocsize = @allocated similar(y) mul!(y, A, x) - @test (@allocated mul!(y, A, x)) == alloc*allocsize + @test (@allocations mul!(y, A, x)) <= alloc end end