First of all... is your modem part of your router or is it separate?
When a DSL modem is training during startup (DSL light flashing) it is testing line conditions and other factors to determine it's best operating speed. This speed determination should remain as long as the modem is not given a reason to retrain. Even with retraining, your connection is still governed by your ISP's speed limits.
Now, if the modem (part of your router or not) is giving you wildly varying speeds, it is very likely something is wrong... most likely with the modem itself or perhaps with your phone line.
I was on DSL pretty much since it started in this area, and over several years my speeds never budged an inch.
So, before you start writing code to pound hell out of your router looking for a 1% speed improvement that gives mostly halucenary benefits, maybe you should get your phone line provider to do some testing on your line...
In the mean time, stop rebooting things... Visit
Speedtest.net - The Global Broadband Speed Test a couple of times a day (not every 5 minutes) and track your speeds over a cople of weeks... If you are experiencing outages on a regular scale, call your service provider and get it fixed.
Finally... be aware some ISPs (Bell Canada being the worst) actually throttle certain kinds of content on the internet, which will greatly affect speeds...
Bell sued for throttling internet speeds - Technology & Science - CBC News
Is there anything to be gained by repeatedly rebooting your modem/router?
Unless you count having to replace it every 6 months as a good thing... no.