20ms for code execution is indeed inordinately high.
You can rule out that the entity skills are responsible for your low FPS.
Perhaps you are calling slow commands in loops with many iterations per frame. However, without knowing the code it is hardly possible to give a precise answer.