Skip to content

Commit bee9806

Browse files
committed
bench: added skf bench
1 parent e52e098 commit bee9806

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

benchmark/benchmarks.jl

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
using BenchmarkTools
2-
32
using ModelPredictiveControl, ControlSystemsBase, LinearAlgebra
3+
44
Ts = 400.0
55
sys = [ tf(1.90,[1800.0,1]) tf(1.90,[1800.0,1]) tf(1.90,[1800.0,1]);
66
tf(-0.74,[800.0,1]) tf(0.74,[800.0,1]) tf(-0.74,[800.0,1]) ]
7-
linmodel = setop!(LinModel(sys, Ts, i_d=[3]), uop=[10,50], yop=[50,30], dop=[5])
7+
8+
const SUITE = BenchmarkGroup()
9+
10+
## ================== SimModel benchmarks =========================================
11+
linmodel = setop!(LinModel(sys, Ts, i_d=[3]), uop=[10, 50], yop=[50, 30], dop=[5])
812
function f!(ẋ, x, u, d, p)
913
mul!(ẋ, p.A, x)
1014
mul!(ẋ, p.Bu, u, 1, 1)
@@ -17,12 +21,9 @@ function h!(y, x, d, p)
1721
return nothing
1822
end
1923
nonlinmodel = NonLinModel(f!, h!, Ts, 2, 4, 2, 1, p=linmodel, solver=nothing)
20-
nonlinmodel = setop!(nonlinmodel, uop=[10,50], yop=[50,30], dop=[5])
21-
u, d = [10, 50], [5]
24+
nonlinmodel = setop!(nonlinmodel, uop=[10, 50], yop=[50, 30], dop=[5])
25+
u, d, y = [10, 50], [5], [50, 30]
2226

23-
const SUITE = BenchmarkGroup()
24-
25-
## ================== SimModel benchmarks =========================================
2627
SUITE["SimModel"]["allocation"] = BenchmarkGroup(["allocation"])
2728
SUITE["SimModel"]["allocation"]["LinModel_updatestate!"] = @benchmarkable(
2829
updatestate!($linmodel, $u, $d),
@@ -47,3 +48,15 @@ SUITE["SimModel"]["allocation"]["NonLinModel_linearize!"] = @benchmarkable(
4748
)
4849

4950
## ================== StateEstimator benchmarks ================================
51+
skf = SteadyKalmanFilter(linmodel)
52+
53+
SUITE["StateEstimator"]["allocation"] = BenchmarkGroup(["allocation"])
54+
SUITE["StateEstimator"]["allocation"]["SteadyKalmanFilter_preparestate!"] = @benchmarkable(
55+
preparestate!($skf, $y, $d),
56+
samples=1
57+
)
58+
SUITE["StateEstimator"]["allocation"]["SteadyKalmanFilter_update!"] = @benchmarkable(
59+
updatestate!($skf, $u, $y, $d),
60+
setup=preparestate!($skf, $y, $d),
61+
samples=1
62+
)

0 commit comments

Comments
 (0)