time estimation

This commit is contained in:
Vincent Riquer 2013-03-24 04:33:42 +01:00
parent 2c868c4131
commit d3daff9593

51
atom
View File

@ -1034,7 +1034,7 @@ copyFile() {
extension="${filename##*.}" extension="${filename##*.}"
commandline="cp -al \"$sourcepath/$filename\" \"$destdir/$destfile.$extension\"" commandline="cp -al \"$sourcepath/$filename\" \"$destdir/$destfile.$extension\""
commandline+=" 2>/dev/null" commandline+=" 2>/dev/null"
commandline+=' || ' commandline+=' AtOM:OR '
commandline+="cp -a \"$sourcepath/$filename\" \"$destdir/$destfile\"" commandline+="cp -a \"$sourcepath/$filename\" \"$destdir/$destfile\""
copytaskid=$( copytaskid=$(
Insert tasks <<-EOInsert Insert tasks <<-EOInsert
@ -1231,7 +1231,7 @@ worker() {
rest=${rest#*|} rest=${rest#*|}
destfilename=${rest%%|*} destfilename=${rest%%|*}
rest=${rest#*|} rest=${rest#*|}
if eval $commandline >/dev/null 2>>"$tempdir/errors.log" if eval ${commandline/AtOM:OR/||} >/dev/null 2>>"$tempdir/errors.log"
then then
echo "finished $taskid|$sourcefileid|$destfileid|$destfilename" echo "finished $taskid|$sourcefileid|$destfileid|$destfilename"
else else
@ -1269,7 +1269,6 @@ master() {
then then
eval echo AtOM:Die '>&'$((100+workerid)) eval echo AtOM:Die '>&'$((100+workerid))
wait ${workers[workerid]} wait ${workers[workerid]}
break
eval $((100+workerid))'>&-' eval $((100+workerid))'>&-'
eval $((200+workerid))'<&-' eval $((200+workerid))'<&-'
rm "$tempdir"/worker${workerid}{in,out} rm "$tempdir"/worker${workerid}{in,out}
@ -1330,7 +1329,7 @@ master() {
unset workers[workerid] unset workers[workerid]
fi fi
;; ;;
'finished') ?(f)'inished')
(( active-- )) || true (( active-- )) || true
taskid=${workerquery%%|*} taskid=${workerquery%%|*}
rest="${workerquery#*|}|" rest="${workerquery#*|}|"
@ -1344,7 +1343,7 @@ master() {
then then
echo \ echo \
"UPDATE destination_files" \ "UPDATE destination_files" \
"SET filename=\"$destfilename\"," \ "SET filename=\"${destfilename//\"/\"\"}\"," \
" last_change=(" \ " last_change=(" \
" SELECT last_change" \ " SELECT last_change" \
" FROM source_files" \ " FROM source_files" \
@ -1405,7 +1404,7 @@ then
fi fi
getConfig getConfig
set -e set -eH
if (( debug )) if (( debug ))
then then
cat <<-EOF cat <<-EOF
@ -1768,6 +1767,7 @@ echo -e "\rCreated ${count:-0} tasks for $filecount files"
rm -f "$tempdir"/worker* rm -f "$tempdir"/worker*
concurrency=$(( maxload / 2 )) concurrency=$(( maxload / 2 ))
(( concurrency )) || concurrency=1
active=0 active=0
for (( i=0 ; i < concurrency ; i++ )) for (( i=0 ; i < concurrency ; i++ ))
do do
@ -1822,34 +1822,61 @@ do
fi fi
fi fi
master master
if ((taskcount - remaining))
then
currenttime=$(date +%s)
secsremaining=$((
remaining
*
(currenttime - starttime)
/
(taskcount - remaining)
))
(( days =
secsremaining
/
( 24*60*60 )
)) || true
(( hours =
( secsremaining - ( days*24*60*60 ) )
/
( 60*60 )
)) || true
(( minutes =
( secsremaining - ( ( days*24 + hours ) *60*60 ) )
/
60
)) || true
fi
echo -en "\rload: $humanload / $maxload" \ echo -en "\rload: $humanload / $maxload" \
"workers: $active / $concurrency" \ "workers: $active / $concurrency" \
"done: $(( (taskcount - remaining ) * 100 / taskcount ))%" \ "done: $(( (taskcount - remaining ) * 100 / taskcount ))%" \
" $((taskcount - remaining)) of $taskcount ($failed failed)" "- $((taskcount - remaining)) of $taskcount ($failed failed)" \
"${days}d ${hours}h${minutes}m "
done done
endtime=$(date +%s) endtime=$(date +%s)
(( elapsedseconds = endtime - starttime )) (( elapsedseconds = endtime - starttime ))
(( days = (( days =
elapsedseconds secsremaining
/ /
( 24*60*60 ) ( 24*60*60 )
)) || true )) || true
(( hours = (( hours =
( elapsedseconds - ( days*24*60*60 ) ) ( secsremaining - ( days*24*60*60 ) )
/ /
( 60*60 ) ( 60*60 )
)) || true )) || true
(( minutes = (( minutes =
( elapsedseconds - ( ( days*24*60*60 ) + ( hours*60*60 ) ) ) ( secsremaining - ( ( days*24 + hours ) *60*60 ) )
/ /
60 60
)) || true )) || true
(( seconds = (( seconds =
elapsedseconds secsremaining
- -
( ( days*24*60*60 ) + ( hours*60*60 ) + ( minutes*60) ) ( ( ( ( days*24 + hours ) *60 ) + minutes ) *60 )
)) || true )) || true
echo -e "\rRan $taskcount tasks, $failed of which failed, in $days" \ echo -e "\rRan $taskcount tasks, $failed of which failed, in $days" \