#!/bin/bash if [[ -z $1 ]] || [[ -z $2 ]] then echo "[!] Execute [./performance_test.sh]" exit 0 fi LOG_FILE=$1 RESULT_FILE=$2 WAIT_FOR_LAUNCH=10 APP_MEMORY=$(sdb shell "memps -v | grep 'Available'" | tail -1) BEFORE_MEMORY=($(echo $APP_MEMORY | awk '{print $5}')) while inotifywait -qqre modify "$LOG_FILE"; do sleep $WAIT_FOR_LAUNCH APP_MEMORY=$(sdb shell "memps -v | grep 'Tizen.exe'" | tail -1) MEMORY_PID=($(echo $APP_MEMORY | awk '{print $1}')) MEMORY_PSS=($(echo $APP_MEMORY | awk '{print $7}')) MEMORY_3D=($(echo $APP_MEMORY | awk '{print $8}')) MEMORY_GEM=($(echo $APP_MEMORY | awk '{print $9}')) APP_MEMORY=$(sdb shell "memps -v | grep 'Available'" | tail -1) AFTER_MEMORY=($(echo $APP_MEMORY | awk '{print $5}')) let MEMORY_FREE=$BEFORE_MEMORY-$AFTER_MEMORY echo -e "PSS\t3D\tGEM\tFREE" | tee -a $RESULT_FILE echo -e "$MEMORY_PSS\t$MEMORY_3D\t$MEMORY_GEM\t$MEMORY_FREE" | tee -a $RESULT_FILE DETAIL_MEMORY=$(sdb shell "memps $MEMORY_PID" | while read line do DETAIL_MEMORY_LIST=$line DETAIL_PCODE=($(echo $DETAIL_MEMORY_LIST | awk '{print $3}' | tr -d '\r')) DETAIL_PDATA=($(echo $DETAIL_MEMORY_LIST | awk '{print $4}' | tr -d '\r')) if [[ $DETAIL_PCODE != "P(CODE)" ]] && [[ $DETAIL_PDATA != "P(DATA)" ]] && [[ $DETAIL_PCODE != "--------" ]] && [[ $DETAIL_PDATA != "--------" ]] then let DETAIL_SUM=$DETAIL_PCODE+$DETAIL_PDATA if [[ $DETAIL_SUM -ge 100 ]] then DETAIL_OBJECT=($(echo $DETAIL_MEMORY_LIST | awk '{print $6}')) echo -n "$DETAIL_SUM\t$DETAIL_OBJECT" echo "" fi fi done | sort -n -r | tr -d '\r' ) echo -e "P(C+D)\tOBJECT NAME" | tee -a $RESULT_FILE for item in ${DETAIL_MEMORY[*]} do echo -e $item | tee -a $RESULT_FILE done echo -e "" | tee -a $RESULT_FILE sleep 3 sdb shell kill -9 $MEMORY_PID sleep $WAIT_FOR_LAUNCH echo -e "T(ms)\tAPP ID" | tee -a $RESULT_FILE APP_MEMORY=$(sdb shell "memps -v | grep 'Available'" | tail -1) BEFORE_MEMORY=($(echo $APP_MEMORY | awk '{print $5}')) done