From 0dd962fb8cf62f1e58de6683a234524ceee650ec Mon Sep 17 00:00:00 2001 From: Vincent Riquer Date: Tue, 11 Feb 2025 21:50:14 +0100 Subject: [PATCH] Enhancement: slight performance improve atom: don't call `date` to get the timestamp multiple times in the main loop --- atom | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/atom b/atom index a0487d2..de9b69a 100755 --- a/atom +++ b/atom @@ -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 ))