Skip to content

Commit ad6ae45

Browse files
committed
bench: ExplicitMPC no-allocation test
1 parent ccdef41 commit ad6ae45

File tree

3 files changed

+11
-16
lines changed

3 files changed

+11
-16
lines changed

benchmark/benchmarks.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,4 +127,15 @@ SUITE["StateEstimator"]["allocation"]["ExtendedKalmanFilter_updatestate!"] = @be
127127
updatestate!($ekf, $u, $y, $d),
128128
setup=preparestate!($ekf, $y, $d),
129129
samples=1
130+
)
131+
132+
## ==================================================================================
133+
## ================== PredictiveController benchmarks ===============================
134+
## ==================================================================================
135+
empc = ExplicitMPC(linmodel)
136+
SUITE["PredictiveController"]["allocation"] = BenchmarkGroup(["allocation"])
137+
SUITE["PredictiveController"]["allocation"]["ExplicitMPC_moveinput!"] = @benchmarkable(
138+
moveinput!($empc, $d),
139+
setup=preparestate!($empc, $y, $d),
140+
samples=1
130141
)

test/2_test_state_estim.jl

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -202,12 +202,9 @@ end
202202
preparestate!(kalmanfilter1, y)
203203
@test updatestate!(kalmanfilter1, u, y, d) zeros(4)
204204
@test kalmanfilter1.x̂0 zeros(4)
205-
@test_skip @allocations(preparestate!(kalmanfilter1, y)) == 0
206-
@test_skip @allocations(updatestate!(kalmanfilter1, u, y)) == 0
207205
preparestate!(kalmanfilter1, y)
208206
@test evaloutput(kalmanfilter1) kalmanfilter1() [50, 30]
209207
@test evaloutput(kalmanfilter1, d) kalmanfilter1(d) [50, 30]
210-
@test_skip @allocations(evaloutput(kalmanfilter1, d)) == 0
211208
@test initstate!(kalmanfilter1, [10, 50], [50, 30+1]) [zeros(3); [1]]
212209
setstate!(kalmanfilter1, [1,2,3,4], diagm(.1:.1:.4))
213210
@test kalmanfilter1.x̂0 [1,2,3,4]
@@ -323,12 +320,9 @@ end
323320
preparestate!(lo1, y)
324321
@test updatestate!(lo1, u, y, d) zeros(4)
325322
@test lo1.x̂0 zeros(4)
326-
@test_skip @allocations(preparestate!(lo1, y)) == 0
327-
@test_skip @allocations(updatestate!(lo1, u, y)) == 0
328323
preparestate!(lo1, y)
329324
@test evaloutput(lo1) lo1() [50, 30]
330325
@test evaloutput(lo1, d) lo1(d) [50, 30]
331-
@test_skip @allocations(evaloutput(lo1, d)) == 0
332326
@test initstate!(lo1, [10, 50], [50, 30+1]) [zeros(3); [1]]
333327
setstate!(lo1, [1,2,3,4])
334328
@test lo1.x̂0 [1,2,3,4]
@@ -454,11 +448,8 @@ end
454448
@test updatestate!(internalmodel1, u, y, d) zeros(2)
455449
@test internalmodel1.x̂d internalmodel1.x̂0 zeros(2)
456450
@test internalmodel1.x̂s ones(2)
457-
@test_skip @allocations(preparestate!(internalmodel1, y)) == 0
458-
@test_skip @allocations(updatestate!(internalmodel1, u, y)) == 0
459451
preparestate!(internalmodel1, y)
460452
@test evaloutput(internalmodel1, d) [51,31]
461-
@test_skip @allocations(evaloutput(internalmodel1, d)) == 0
462453
@test initstate!(internalmodel1, [10, 50], [50, 30]) zeros(2)
463454
@test internalmodel1.x̂s zeros(2)
464455
setstate!(internalmodel1, [1,2])
@@ -590,12 +581,9 @@ end
590581
preparestate!(ukf1, y)
591582
@test updatestate!(ukf1, u, y, d) zeros(4) atol=1e-9
592583
@test ukf1.x̂0 zeros(4) atol=1e-9
593-
@test_skip @allocations(preparestate!(ukf1, y)) == 0
594-
@test_skip @allocations(updatestate!(ukf1, u, y)) == 0
595584
preparestate!(ukf1, y)
596585
@test evaloutput(ukf1) ukf1() [50, 30]
597586
@test evaloutput(ukf1, d) ukf1(d) [50, 30]
598-
@test_skip @allocations(evaloutput(ukf1, d)) == 0
599587
@test initstate!(ukf1, [10, 50], [50, 30+1]) zeros(4) atol=1e-9
600588
setstate!(ukf1, [1,2,3,4], diagm(.1:.1:.4))
601589
@test ukf1.x̂0 [1,2,3,4]
@@ -749,12 +737,9 @@ end
749737
preparestate!(ekf1, y)
750738
@test updatestate!(ekf1, u, y, d) zeros(4) atol=1e-9
751739
@test ekf1.x̂0 zeros(4) atol=1e-9
752-
@test_skip @allocations(preparestate!(ekf1, y)) == 0
753-
@test_skip @allocations(updatestate!(ekf1, u, y)) == 0
754740
preparestate!(ekf1, y)
755741
@test evaloutput(ekf1) ekf1() [50, 30]
756742
@test evaloutput(ekf1, d) ekf1(d) [50, 30]
757-
@test_skip @allocations(evaloutput(ekf1, d)) == 0
758743
@test initstate!(ekf1, [10, 50], [50, 30+1]) zeros(4);
759744
setstate!(ekf1, [1,2,3,4], diagm(.1:.1:.4))
760745
@test ekf1.x̂0 [1,2,3,4]

test/3_test_predictive_control.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,6 @@ end
496496
@test u [1] atol=1e-2
497497
u = mpc1(r)
498498
@test u [1] atol=1e-2
499-
@test_skip @allocations(moveinput!(mpc1, r)) == 0
500499
info = getinfo(mpc1)
501500
@test info[:u] u
502501
@test info[:Ŷ][end] r[1] atol=1e-2

0 commit comments

Comments
 (0)