This answer, of course, will not always be applicable, but if the main mode turns out to be irrelevant for the macro under consideration, then a good way to improve the keyboard macro execution speed is to switch the buffer to the main mode first. In some cases, which can provide a significant increase in speed, since you eliminate the overhead of primary and secondary modes.
If changing the main modes is not possible, you can still get significant benefit from turning off some of the secondary modes for a duration.
However, according to the accepted answer and comments, if there is enough search and replacement, it will always be much faster than any macro.
source share