Enhancement: slight performance improve

atom: don't call `date` to get the timestamp multiple times in the main loop
This commit is contained in:
Vincent Riquer 2025-02-11 21:50:14 +01:00
parent 042cd72ecd
commit 0dd962fb8c

13
atom
View File

@ -708,10 +708,11 @@ echo 'BEGIN TRANSACTION;' >&3
committime=$(date +%s)
while (( (remaining || ${#workers[@]}) && ! quit ))
do
if (( $(date +%s) - committime >= 60 ))
timestamp=$(date +%s)
if (( $timestamp - committime >= 60 ))
then
echo $'COMMIT;\nBEGIN TRANSACTION;' >&3
committime=$(date +%s)
committime=$timestamp
fi
read humanload garbage < /proc/loadavg
load=${humanload%.*}
@ -721,16 +722,16 @@ do
else
if [ -z "$quit" ] \
&& (( ! pause )) \
&& (( $(date +%s)-concurrencychange >= loadinterval ))
&& (( timestamp - concurrencychange >= loadinterval ))
then
if (( concurrency > 1 )) \
&& (( load > maxload ))
then
concurrencychange=$(date +%s)
concurrencychange=$timestamp
(( --concurrency ))
elif (( load < maxload )) && (( active > concurrency - 1 ))
then
concurrencychange=$(date +%s)
concurrencychange=$timestamp
(( ++concurrency ))
fi
fi
@ -740,7 +741,7 @@ do
(( pause )) || master
if (( ran - failed ))
then
currenttime=$(date +%s)
currenttime=$timestamp
if (( pause ))
then
(( runtime = pausestart - starttime - pausedtime ))