The proper approach to this, as practiced in places like Switzerland, is to drive at a speed that you get greens, not accelerating to linespeed then stopping again. In countries who know how to operate railways properly, this is part of the working timetable, and often even core to the signalling system.
It is absolutely not a fool's errand, it is the only way to make a railway truly punctual - never run things to their maximum capability, always keep some capacity spare in case you need to catch up a delay.