Skip to content

Commit 8f60903

Browse files
Merge pull request #94 from LilithHafner/lh/add-tests
Add performance tests for (General)LazyBufferCaches
2 parents 6c83dde + 060d364 commit 8f60903

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

test/general_lbc.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,14 @@ fnc = OptimizationFunction(negloglik, Optimization.AutoForwardDiff())
3232
prob = OptimizationProblem(fnc, θ₀, (yᵒ, n, ε), lb = [-10.0, 1e-6, 0.5],
3333
ub = [10.0, 10.0, 25.0])
3434
solve(prob, LBFGS())
35+
36+
cache = LazyBufferCache()
37+
x = rand(1000)
38+
@inferred cache[x]
39+
@test 0 == @allocated cache[x]
40+
41+
cache = GeneralLazyBufferCache(T -> Vector{T}(undef, 1000))
42+
# GeneralLazyBufferCache is documented not to infer.
43+
# @inferred cache[Float64]
44+
cache[Float64] # generate the buffer
45+
@test 0 == @allocated cache[Float64]

0 commit comments

Comments
 (0)