This example illustrates the impact of Modelica code formulations on the C-code.
Compare the C-code in dsmodel.c when setting the parameter
efficient
to true
or false
and when adding annotation(Evaluate=true)
to the parameter efficient
.
This produces:
helpvar[0] = sin(Time); F_[0] = helpvar[0]*(IF DP_[0] THEN W_[0] ELSE DP_[1]+DP_[2]+DP_[3]);
helpvar[0] = sin(Time); F_[0] = helpvar[0]*(DP_[0]+DP_[1]+DP_[2]);
helpvar[0] = sin(Time); F_[0] = helpvar[0]*W_[1];
The last option requires much less operations to be performed and is therefore more efficient.
See Jorissen et al. (2015) for a discussion.