Skip to content

Commit

Permalink
Smaller benchmarks (#157)
Browse files Browse the repository at this point in the history
* Stop benchmarking set types

* Benchmark local shared Hessians

* Spend more time on NLPModels benchmark
  • Loading branch information
adrhill authored Aug 12, 2024
1 parent 9da81a1 commit f1ec8b1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 39 deletions.
50 changes: 15 additions & 35 deletions benchmark/bench_jogger.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,46 +3,26 @@ Pkg.develop(; path=joinpath(@__DIR__, "SparseConnectivityTracerBenchmarks"))

using BenchmarkTools
using SparseConnectivityTracer
using SparseConnectivityTracer: GradientTracer, HessianTracer
using SparseConnectivityTracer: IndexSetGradientPattern, IndexSetHessianPattern
using SparseConnectivityTracer: DuplicateVector, SortedVector, RecursiveSet
using SparseConnectivityTracer: Shared, NotShared

SET_TYPES = (BitSet, Set{Int}, DuplicateVector{Int}, RecursiveSet{Int}, SortedVector{Int})
using SparseConnectivityTracer: HessianTracer, DictHessianPattern, Shared

include("jacobian.jl")
include("hessian.jl")
include("nlpmodels.jl")

suite = BenchmarkGroup()

suite["OptimizationProblems"] = optbench([:britgas])

for S1 in SET_TYPES
S2 = Set{Tuple{Int,Int}}

# Non-shared tracers
PG = IndexSetGradientPattern{Int,S1}
PH = IndexSetHessianPattern{Int,S1,S2,NotShared}
G = GradientTracer{PG}
H = HessianTracer{PH}

suite["Jacobian"]["Global"][nameof(S1)] = jacbench(TracerSparsityDetector(G, H))
suite["Jacobian"]["Local"][nameof(S1)] = jacbench(TracerLocalSparsityDetector(G, H))
suite["Hessian"]["Global"][(nameof(S1), nameof(S2))] = hessbench(
TracerSparsityDetector(G, H)
)
suite["Hessian"]["Local"][(nameof(S1), nameof(S2))] = hessbench(
TracerLocalSparsityDetector(G, H)
)

# Shared tracers
PG = IndexSetGradientPattern{Int,S1}
PH = IndexSetHessianPattern{Int,S1,S2,Shared}
G = GradientTracer{PG}
H = HessianTracer{PH}

suite["Hessian"]["Global (shared)"][(nameof(S1), nameof(S2))] = hessbench(
TracerSparsityDetector(G, H)
)
end
suite["Jacobian"]["Global"] = jacbench(TracerSparsityDetector())
suite["Jacobian"]["Local"] = jacbench(TracerLocalSparsityDetector())
suite["Hessian"]["Global"] = hessbench(TracerSparsityDetector())
suite["Hessian"]["Local"] = hessbench(TracerLocalSparsityDetector())

# Shared tracers
P = DictHessianPattern{Int,BitSet,Dict{Int,BitSet},Shared}
H = HessianTracer{P}
suite["Hessian"]["Global shared"] = hessbench(
TracerSparsityDetector(; hessian_tracer_type=H)
)
suite["Hessian"]["Local shared"] = hessbench(
TracerLocalSparsityDetector(; hessian_tracer_type=H)
)
6 changes: 2 additions & 4 deletions benchmark/nlpmodels.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ function optbench(names::Vector{Symbol})
suite = BenchmarkGroup()
for name in names
nlp = ADNLPProblems.eval(name)()
suite[name]["Jacobian"] = @benchmarkable compute_jac_sparsity_sct($nlp) evals = 1 samples =
1
suite[name]["Hessian"] = @benchmarkable compute_hess_sparsity_sct($nlp) evals = 1 samples =
1
suite[name]["Jacobian"] = @benchmarkable compute_jac_sparsity_sct($nlp)
suite[name]["Hessian"] = @benchmarkable compute_hess_sparsity_sct($nlp)
end
return suite
end

0 comments on commit f1ec8b1

Please sign in to comment.