Here, dynamic method dispatch
provides nothing more than way to stall branch prediction in the CPU
which is very bad. As a modern CPU can have ten stage pipeline (or
more), stalling it can mean losing a factor of ten or more in
performance. [Steve Railsback, et. al. wrote a comparison of agent
based modeling toolkits, and Swarm did very poorly in some cases due to
this when I looked at one of the cases with hardware profiling (Intel
VTune).] Either member functions (e.g. typed messages), or inline
conditionals will be far more efficient.
As usual, you put optimization up front in the modeling task. And
that's not the point. It doesn't matter, from a modeling perspective,
how the feature is implemented as long as all the requirements are met.