Performance of local_state_space_iteration_*
local_state_space_iteration_2 MEX is much faster than
local_state_space_iteration_k at order 2.
This performance differential should be investigated. But it is likely that the Dynare++ engine for simulating the model is not very well optimized.
The solution is either to improve the performance of the Dynare++ code, or to fully rewrite it without using Dynare++ codebase (and by the way, do that in Fortran).