Last active
January 21, 2016 04:12
-
-
Save lexszero/03b959b70ba31b3441d7 to your computer and use it in GitHub Desktop.
bash_dbg.sh
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
#!/bin/bash | |
file_log=`mktemp` | |
file_tim=`mktemp` | |
cleanup_tracing_files() { | |
rm -f $file_log $file_tim | |
unset file_log file_tim crt last | |
} | |
trap cleanup_tracing_files EXIT | |
exec 3>&2 2> >( | |
tee $file_log | | |
sed -u 's/^.*$/now/' | | |
date -f - +%s.%N >$file_tim | |
) | |
set -x | |
#source "$@" | |
bash -x "$@" | |
set +x | |
exec 2>&3 3>&- | |
paste <( | |
last=0 | |
while read tim ;do | |
[[ -z "$first" ]] && first=${tim//.} | |
crt=000000000$((${tim//.}-10#0$last)) | |
printf "%12.9f\n" ${crt:0:${#crt}-9}.${crt:${#crt}-9} | |
last=${tim//.} | |
done < $file_tim | |
crt=000000000$(($last-10#0$first)) | |
echo | |
printf "Total: %12.9f\n" ${crt:0:${#crt}-9}.${crt:${#crt}-9} | |
) $file_log | |
cleanup_tracing_files |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment