Created
June 21, 2014 11:57
-
-
Save itiut/7a70ca0b076c7dcc895a to your computer and use it in GitHub Desktop.
sqlの出力結果から実行時間を抜き出す
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
#!/bin/sh | |
set -eux | |
cd $(dirname $0) | |
# for i in {1..22}; do LINE=`wc -l $i.out | cut -d ' ' -f 1`; grep -e "^select$" -A $LINE $i.out | grep -o -e "[[:digit:]]\+\.[[:digit:]]\+ sec)" -m 1 | cut -d ' ' -f 1 | sed "s/^/$i /g"; done > execution_time.dat | |
parse_execution_time() { | |
local qout=$1 | |
local status_line=$(grep -n '| Status *| Duration *|' $qout | cut -d ':' -f 1) | |
tail -n +$((status_line + 2)) $qout | grep '^|' | sed 's/^| \| |$//g' | sed 's/ *| */,/g' > time$qout | |
} | |
if [ $# -ne 1 ]; then | |
echo "Usage: [$0] directory" | |
exit | |
fi | |
cd $1 | |
for i in $(seq 1 22); do | |
parse_execution_time q$i.out | |
awk -F , "{ sum = sum + \$2 } END{ print sum }" time$i.out >> execution_time.dat | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment