Again -- instantiation time. If you haven't seen it, look at this post I did with timings.
If JXA/AS/shell script can provide functionality that KM doesn't have, use a script. If a single JXA/AS/shell action can replace many KM actions (which includes a loop structure with many iterations), use a script. But don't replace simple KM actions with simple JXA/AS/shell actions to try and increase performance, it rarely works.