City-of-Bloomington / timetrack

Digital time keeping system with both a web-based calendar entry and a kiosk based badge entry interface
GNU General Public License v2.0
78 stars 2 forks source link

Javascript on Timeclock screen locks CPU #287

Open inghamn opened 2 years ago

inghamn commented 2 years ago

On the Raspberry PI timeclocks, the webpage they load sends the CPU to 100% usage, all the time. The wastes electricty, and causes the Raspberry PI to run very hot.

The culprit is a 10ms timeout loop that is meant to update the time displayed on the webpage (every 10 milliseconds). If we don't need per-second accuracy displayed on the timeclock, we don't need this CPU consuming loop.

inghamn commented 2 years ago

We saved a ton of CPU by doing the clock updates only once a second, rather than every 10 milliseconds. Further improvements can be had by replacing the custom formatting code with Date().toLocaleString(). However, this would require some HTML markup changes.