- # this is our first run
- # just wait the requested time
- if [ ${LOOPSLEEPMS_LASTRUN} -eq 0 ]
- then
- LOOPSLEEPMS_LASTWORK=0
- else
- # calculate ms since last run
- LOOPSLEEPMS_LASTWORK=$((now_ms - LOOPSLEEPMS_LASTRUN - LOOPSLEEPMS_LASTSLEEP))
- fi
+ # calculate ms since last run
+ [ ${LOOPSLEEPMS_LASTRUN} -gt 0 ] && \
+ LOOPSLEEPMS_LASTWORK=$((now_ms - LOOPSLEEPMS_LASTRUN - LOOPSLEEPMS_LASTSLEEP + current_time_ms_accuracy))