Stepper misses steps on low speeds

Perhaps because you are changing the speed many times per step, which will confuse the calculations of the current step - for instance by changing between 0 and 1 speed repeatedly during a single step - I can't imagine the author of the library imagined setSpeed() would be called 10000 times a second.

If you monitor the currentPosition(), you can do the speed update no faster than the step rate, for instance.