Skip to content

Commit

Permalink
Merge pull request #94 from LilithHafner/lh/add-tests
Browse files Browse the repository at this point in the history
Add performance tests for (General)LazyBufferCaches
  • Loading branch information
ChrisRackauckas authored Jan 3, 2024
2 parents 6c83dde + 060d364 commit 8f60903
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 8f60903

Please sign in to comment.