Skip to content

Commit

Permalink
Add performance tests for (General)LazyBufferCaches
Browse files Browse the repository at this point in the history
  • Loading branch information
LilithHafner committed Jan 3, 2024
1 parent 6c83dde commit 060d364
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions test/general_lbc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,14 @@ fnc = OptimizationFunction(negloglik, Optimization.AutoForwardDiff())
prob = OptimizationProblem(fnc, θ₀, (yᵒ, n, ε), lb = [-10.0, 1e-6, 0.5],
ub = [10.0, 10.0, 25.0])
solve(prob, LBFGS())

cache = LazyBufferCache()
x = rand(1000)
@inferred cache[x]
@test 0 == @allocated cache[x]

cache = GeneralLazyBufferCache(T -> Vector{T}(undef, 1000))
# GeneralLazyBufferCache is documented not to infer.
# @inferred cache[Float64]
cache[Float64] # generate the buffer
@test 0 == @allocated cache[Float64]

0 comments on commit 060d364

Please sign in to comment.