From f1ec8b1e0c206429ec6eb289a740feba2ee88582 Mon Sep 17 00:00:00 2001 From: Adrian Hill Date: Mon, 12 Aug 2024 16:47:30 +0200 Subject: [PATCH] Smaller benchmarks (#157) * Stop benchmarking set types * Benchmark local shared Hessians * Spend more time on NLPModels benchmark --- benchmark/bench_jogger.jl | 50 ++++++++++++--------------------------- benchmark/nlpmodels.jl | 6 ++--- 2 files changed, 17 insertions(+), 39 deletions(-) diff --git a/benchmark/bench_jogger.jl b/benchmark/bench_jogger.jl index 32887c2..70aecda 100644 --- a/benchmark/bench_jogger.jl +++ b/benchmark/bench_jogger.jl @@ -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) +) diff --git a/benchmark/nlpmodels.jl b/benchmark/nlpmodels.jl index a2711ae..7310d2c 100644 --- a/benchmark/nlpmodels.jl +++ b/benchmark/nlpmodels.jl @@ -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