Created
October 27, 2020 00:47
-
-
Save hiraksarkar/7e295035698c3907c8f6a2b31a28752b to your computer and use it in GitHub Desktop.
extract_json_from_time
This file contains hidden or 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
#!/usr/bin/bash | |
tfile=$1 | |
usr=`rg "(\d+\.\d+)user" $tfile -or '$1'` | |
sys=`rg "(\d+\.\d+)system" $tfile -or '$1'` | |
elap=`rg "([\d:\.]+)elapsed" $tfile -or '$1'` | |
mem=`rg "(\d+)maxresident" $tfile -or '$1'` | |
tot_elap=`echo "$elap" | sed -E 's/(.*):(.+):(.+)/\1*3600+\2*60+\3/;s/(.+):(.+)/\1*60+\2/' | bc` | |
echo "{ " | |
echo "\"user\": $usr," | |
echo "\"sys\": $sys," | |
echo "\"elapsed\": $tot_elap," | |
echo "\"mem\": $mem" | |
echo "}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment