From b735d4ff07d67dfb366455cda13e96690859674a Mon Sep 17 00:00:00 2001 From: franckgaga Date: Fri, 28 Nov 2025 15:20:28 -0500 Subject: [PATCH 1/2] bench: added `getinfo` function in unit tests --- benchmark/2_bench_state_estim.jl | 14 +++++++++++++- benchmark/3_bench_predictive_control.jl | 18 ++++++++++++++++++ benchmark/benchmarks.jl | 4 ++-- 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/benchmark/2_bench_state_estim.jl b/benchmark/2_bench_state_estim.jl index d49005861..e52e9d15b 100644 --- a/benchmark/2_bench_state_estim.jl +++ b/benchmark/2_bench_state_estim.jl @@ -172,6 +172,12 @@ UNIT_ESTIM["MovingHorizonEstimator"]["updatestate!"]["LinModel"]["Prediction for setup=preparestate!($mhe_lin_pred, $y, $d), samples=samples, evals=evals, seconds=seconds, ) +UNIT_ESTIM["MovingHorizonEstimator"]["getinfo!"]["LinModel"] = + @benchmarkable( + getinfo($mhe_lin_curr), + setup=preparestate!($mhe_lin_curr, $y, $d), + samples=samples, evals=evals, seconds=seconds, + ) UNIT_ESTIM["MovingHorizonEstimator"]["preparestate!"]["NonLinModel"]["Current form"] = @benchmarkable( preparestate!($mhe_nonlin_curr, $y, $d), @@ -193,7 +199,13 @@ UNIT_ESTIM["MovingHorizonEstimator"]["updatestate!"]["NonLinModel"]["Prediction updatestate!($mhe_nonlin_pred, $u, $y, $d), setup=preparestate!($mhe_nonlin_pred, $y, $d), samples=samples, evals=evals, seconds=seconds, - ) + ) +UNIT_ESTIM["MovingHorizonEstimator"]["getinfo!"]["NonLinModel"] = + @benchmarkable( + getinfo($mhe_nonlin_curr), + setup=preparestate!($mhe_nonlin_curr, $y, $d), + samples=samples, evals=evals, seconds=seconds, + ) ## ---------------------------------------------------------------------------------------- ## ----------------- CASE STUDIES --------------------------------------------------------- diff --git a/benchmark/3_bench_predictive_control.jl b/benchmark/3_bench_predictive_control.jl index 6fe380fe9..374bdcd45 100644 --- a/benchmark/3_bench_predictive_control.jl +++ b/benchmark/3_bench_predictive_control.jl @@ -25,6 +25,12 @@ UNIT_MPC["LinMPC"]["moveinput!"]["MultipleShooting"] = setup=preparestate!($linmpc_ms, $y, $d), samples=samples, evals=evals, seconds=seconds ) +UNIT_MPC["LinMPC"]["getinfo!"] = + @benchmarkable( + getinfo($linmpc_ss), + setup=(preparestate!($linmpc_ss, $y, $d); moveinput!($linmpc_ss, $y, $d)), + samples=samples, evals=evals, seconds=seconds + ) empc = ExplicitMPC(linmodel, Mwt=[1, 1], Nwt=[0.1, 0.1], Lwt=[0.1, 0.1], Hp=10) @@ -76,6 +82,12 @@ UNIT_MPC["NonLinMPC"]["moveinput!"]["LinModel"]["MultipleShooting"] = setup=preparestate!($nmpc_lin_ms, $y, $d), samples=samples, evals=evals, seconds=seconds ) +UNIT_MPC["NonLinMPC"]["getinfo!"]["LinModel"] = + @benchmarkable( + getinfo($nmpc_lin_ss), + setup=(preparestate!($nmpc_lin_ss, $y, $d); moveinput!($nmpc_lin_ss, $y, $d)), + samples=samples, evals=evals, seconds=seconds + ) UNIT_MPC["NonLinMPC"]["moveinput!"]["NonLinModel"]["SingleShooting"] = @benchmarkable( moveinput!($nmpc_nonlin_ss, $y, $d), @@ -106,6 +118,12 @@ UNIT_MPC["NonLinMPC"]["moveinput!"]["NonLinModel"]["TrapezoidalCollocation"] = setup=preparestate!($nmpc_nonlin_tc, $y_c, $d_c), samples=samples, evals=evals, seconds=seconds ) +UNIT_MPC["NonLinMPC"]["getinfo!"]["NonLinModel"] = + @benchmarkable( + getinfo($nmpc_nonlin_ss), + setup=(preparestate!($nmpc_nonlin_ss, $y, $d); moveinput!($nmpc_nonlin_ss, $y, $d)), + samples=samples, evals=evals, seconds=seconds + ) ## ---------------------------------------------------------------------------------------- ## ---------------------- CASE STUDIES ---------------------------------------------------- diff --git a/benchmark/benchmarks.jl b/benchmark/benchmarks.jl index 914ff804a..5e25fbcdd 100644 --- a/benchmark/benchmarks.jl +++ b/benchmark/benchmarks.jl @@ -8,6 +8,6 @@ SUITE["UNIT TESTS"] = BenchmarkGroup(["allocation-free", "allocations", "singl SUITE["CASE STUDIES"] = BenchmarkGroup(["performance", "speed" ,"integration"]) include("0_bench_setup.jl") -include("1_bench_sim_model.jl") +#include("1_bench_sim_model.jl") include("2_bench_state_estim.jl") -include("3_bench_predictive_control.jl") +#include("3_bench_predictive_control.jl") From e7beb7407a715aa1e03879af5ed13884f0ef3a68 Mon Sep 17 00:00:00 2001 From: franckgaga Date: Fri, 28 Nov 2025 15:40:01 -0500 Subject: [PATCH 2/2] bench: remove commented-out code --- benchmark/benchmarks.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/benchmark/benchmarks.jl b/benchmark/benchmarks.jl index 5e25fbcdd..914ff804a 100644 --- a/benchmark/benchmarks.jl +++ b/benchmark/benchmarks.jl @@ -8,6 +8,6 @@ SUITE["UNIT TESTS"] = BenchmarkGroup(["allocation-free", "allocations", "singl SUITE["CASE STUDIES"] = BenchmarkGroup(["performance", "speed" ,"integration"]) include("0_bench_setup.jl") -#include("1_bench_sim_model.jl") +include("1_bench_sim_model.jl") include("2_bench_state_estim.jl") -#include("3_bench_predictive_control.jl") +include("3_bench_predictive_control.jl")