Created
March 14, 2019 09:14
-
-
Save yun-cloud/8bbc6c5a8f70be393f5eab7af95afee5 to your computer and use it in GitHub Desktop.
extract instmix.out into a csv file
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 | |
SRCS=(I0.out I3.out R0.out R3.out) | |
RESULT=instmix.csv | |
dynamic_counts_range() { | |
SRC=$1 | |
TARGET=$2 | |
START=$(cat -n ${SRC} | grep dynamic-counts | awk '{print $1}') | |
END=$(cat -n ${SRC} | grep eof | awk '{print $1}') | |
RANGE=$((${END} - ${START} - 3)) | |
echo ${RANGE} | |
} | |
SRC=${SRCS[0]} | |
TARGET=opcode.tmp | |
RANGE=$(dynamic_counts_range ${SRC} ${TARGET}) | |
tail -n -${RANGE} ${SRC} | head -n -1 | awk '{print $1","$2}' > ${TARGET} | |
for SRC in "${SRCS[@]}"; do | |
TARGET="${SRC%.*}.tmp" | |
RANGE=$(dynamic_counts_range ${SRC} ${TARGET}) | |
tail -n -${RANGE} ${SRC} | head -n -1 | awk '{print $1","$3}' > ${TARGET} | |
done | |
JOIN="join -e 0 -a1 -a2 --nocheck-order -t ," | |
TMPFILE=buf.tmp | |
${JOIN} -o 0 1.2 2.2 opcode.tmp "${SRCS[0]%.*}.tmp" | \ | |
${JOIN} -o 0 1.2 1.3 2.2 - "${SRCS[1]%.*}.tmp" | \ | |
${JOIN} -o 0 1.2 1.3 1.4 2.2 - "${SRCS[2]%.*}.tmp" | \ | |
${JOIN} -o 0 1.2 1.3 1.4 1.5 2.2 - "${SRCS[3]%.*}.tmp" > ${TMPFILE} | |
echo "opcode,inst,${SRCS[0]%.*},${SRCS[1]%.*},${SRCS[2]%.*},${SRCS[3]%.*}" > ${RESULT} | |
cat ${TMPFILE} >> ${RESULT} | |
rm *.tmp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment