HLA Toolbox speed optimization

Home » Blog » Tips » HLA Toolbox speed optimization

HLA Toolbox speed optimization

MATLAB is a powerful environment allowing users to control almost every aspect of code execution. This flexibility sometimes come at the expense of execution speed. In a distributed simulation environment, the need to process callbacks with a high incoming rate is common and it’s achievable using the HLA Toolbox.

The HLA Toolbox receive the callbacks from the RTI in a string format that needs to be executed by feval(). The result is a fluid experience and an easy access to debugging information. This flexibility is limited in speed due to the feval call that is not suitable for high speed execution. The HLA Toolbox as been designed to be able to directly call the MATLAB engine removing the need to parse the callbacks with feval. This mode makes it harder to debug the callbacks code but provides an important execution speed improvement.

In a real world scenario where a federate is  set to receive 50 000 entity updates and send 100 000 entity updates, the time to process all these calls and callbacks went down by more then 75%. A speed improvement of more than 400%!

To activate the UseMexCall in the HLA Toolbox, you just have to enable it from the HLAToolbox preferences:

>> setpref('ForwardSim_HLAToolbox', 'UseMexCall', 1) % activate the UseMexCall

You can switch it back off using

>> setpref('ForwardSim_HLAToolbox', 'UseMexCall', 0) % desactivate the UseMexCall

In summary, when your MATLAB scripts are validated and run as expected, you can use the UseMexCall option to improve the execution speed of your MATLAB federate. Otherwise, stick to the normal mode.


Leave a Comment