Skip to main content

Posts

[bash-script/gcc] check warning of make within git-diff of commit

When you need check "make warning" in specific commits, you can use this script to check just in some commits. This script takes some steps. step1. You must know your commit hash. : like abcd1234 step2. Checkout to your commit.  Like this, git checkout abcd1234. step3. You need output file that run make.  Try to run command "make &> myoutput" step4. Then run this. ./new_warning.sh abcd1234 myoutput You can download this script :  new_warning.sh

[Excel] linux time result calulate

  B5: real+user+sys B5: =(LEFT(B2,FIND("m",B2)-1)*60+MID(B2, FIND("m",B2)+1,5))+(LEFT(B3,FIND("m",B3)-1)*60+MID(B3, FIND("m",B3)+1,5))+(LEFT(B4,FIND("m",B4)-1)*60+MID(B4, FIND("m",B4)+1,5))

[linux/bash script] time command result sum

calc_alltime.sh #!/bin/bash TIME_RESULT_FILE=${1} if [ "${TIME_RESULT_FILE}" != "" ]; then   if [ -f ${TIME_RESULT_FILE} ]; then   egrep "^[rus]" ${TIME_RESULT_FILE} |awk ' { print $2 } '| sed -e 's/m/ /'g |sed -e 's/s$//g' |  awk ' { SUM_MIN=SUM_MIN+$1; SUM_SEC=SUM_SEC+$2; } END {  NEW_MIN=int(SUM_SEC/60);  SUM_MIN=SUM_MIN+NEW_MIN;  SUM_SEC=SUM_SEC-(NEW_MIN*60);  print SUM_MIN "m" SUM_SEC "s" } '   else     echo "File not exist"   fi fi example of FILE # cat tt 1th try real    0m2.564s user    0m0.032s sys     0m0.033s 2th try real    0m2.586s user    0m0.039s sys     0m0.034s 3th try real    0m2.810s user    0m0.036s sys     0m0.042s 4th try real    0m3.155s user    0m0.042s sys     0m0.040s # calc_alltime.sh tt 0m11.413s

[bash-script] git log with refs of body

git log with refs of body #!/bin/bash COMMITS=${1} DELIMITER="|" RET_GITLOG=`git log --format=format:"${DELIMITER} %h ${DELIMITER} %s ${DELIMITER}" ${COMMITS}` HEADER="${DELIMITER} Hash ${DELIMITER} Subject ${DELIMITER} Refs ${DELIMITER}" function func_append_refs {   while true   do     read -r MY_LINE     if [ "${MY_LINE}" == "" ]; then       return     fi     COMMIT_HASH=`echo "${MY_LINE}" | awk -F "${DELIMITER}" ' { print $2 } '`     REFS_LOG=`git log -1 ${COMMIT_HASH} --format=format:'%b' | egrep -i "refs|fix"`     echo "${MY_LINE} ${REFS_LOG} |"   done } echo "${HEADER}" echo "${RET_GITLOG}" | func_append_refs

[bash-script] vsz, rss logger for one process

#!/bin/bash BIN_PROC_FILES="my_bin" LOG_FILE=/tmp/memlog.log RM_LOG_FILE=0 G_STDOUTPUT=1 function write_log {   CUR_TIME_STR=`date +"%Y%m%d_%H%M%S"`   if [ ${G_STDOUTPUT} -gt 0 ]; then     echo "${CUR_TIME_STR} $1"   fi   if [ "${LOG_FILE}" != "" ] ; then     echo "${CUR_TIME_STR} $1" >> ${LOG_FILE}   fi } function loop_proc {   for CUR_BIN in ${BIN_PROC_FILES}   do     PID_SNIPER=`pidof ${CUR_BIN}`     if [ "${PID_SNIPER}" != "" ]; then       MEM_STATS=`ps --pid ${PID_SNIPER} -o rss,vsz`       LINE_CNT=`echo "${MEM_STATS}" | wc -l`       if [ ${LINE_CNT} -gt 1 ]; then         MEM_STAT=`echo "${MEM_STATS}" |tail -n 1`       fi       write_log "${CUR_BIN} ${PID_SNIPER} ${MEM_STAT}"     fi   done } if [ ${RM_LOG_FILE} -gt 0 ]; then   if [ "${LOG_FILE}" != "" ] ; then     rm ${LOG_FILE}   fi fi while true do   loop