Last active
March 28, 2023 23:39
-
-
Save ramiabraham/e9793ead983a963e1806ce73bb50c434 to your computer and use it in GitHub Desktop.
Determines the amount of execution time for a process.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Output in minutes: | |
START=$(date +%s) | |
END=$(date +%s) | |
DIFF=$(( $END - $START )) | |
DIFF=$(( $DIFF / 60 )) | |
echo DIFF | |
# Full output: | |
res1=$(date +%s.%N) | |
# do stuff in here | |
res2=$(date +%s.%N) | |
dt=$(echo "$res2 - $res1" | bc) | |
dd=$(echo "$dt/86400" | bc) | |
dt2=$(echo "$dt-86400*$dd" | bc) | |
dh=$(echo "$dt2/3600" | bc) | |
dt3=$(echo "$dt2-3600*$dh" | bc) | |
dm=$(echo "$dt3/60" | bc) | |
ds=$(echo "$dt3-60*$dm" | bc) | |
printf "Total runtime: %d:%02d:%02d:%02.4f\n" $dd $dh $dm $ds |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment