Timing Freelance Programs
what would be the preferred way to time Freelance programs?
My setup is the following: I'm testing numerical routines for model-based control written in SCL on an Emulator and an AC 800F (16 MB). There are multiple vector/matrix calculations involved as well as square roots. I'd like to obtain an indicator for system load/reserves as well as how well the algorithm scales when computing multiple control loops.
In common PC-based high-level languages, I'd use a timing command offered by the OS, or compare the system timer before and after the routine in question. In Freelance, alas, I cannot seem to obtain <RES>.DateTime from SCL for syntax reasons, and even if I could, I'm not sure if it yielded meaningful values even if I accessed it directly (i.e. not over process image/without "@").
Thanks for any hints or insights,
Voted best answer
using <RES>.DateTime on the AC800F should be fine for your purpose if you use it with and without Process image at appropriate times. You can convert it to something you can handle or can convert the difference.
On the AC800F you can observe the CPU load changes with and without your calculation task running.
I am not sure about the resolution right now, but I think it is not bigger than 5ms.
On the diagnostic web page there is a task scheduling summary, giving min/average/max execution times. Redundant controllers give different results for redundant tasks.
It is possible to control the priority of multiple application tasks, but most system tasks have higher priority.
If Emulator means Freelance emulator, it is more difficult. In current versions the DateTime variable is updated twice a second or so. Function blocks like M_GEN or TREND will have a better time, but I just have no idea how to access it in the controller. It would be possible to evaluate the trend archive offline or to have an OPC alarm client tracking the MGEN alarms.