Bug-fix : native library resolving logic
[platform/core/dotnet/launcher.git] / tools / Performance / memorystamp.sh
1 #!/bin/bash
2
3 if [[ -z $1 ]] || [[ -z $2 ]]
4 then
5     echo "[!] Execute [./performance_test.sh]"
6     exit 0
7 fi
8
9 LOG_FILE=$1
10 RESULT_FILE=$2
11 WAIT_FOR_LAUNCH=10
12
13 APP_MEMORY=$(sdb shell "memps -v | grep 'Available'" | tail -1)
14 BEFORE_MEMORY=($(echo $APP_MEMORY | awk '{print $5}'))
15 while inotifywait -qqre modify "$LOG_FILE"; do
16     sleep $WAIT_FOR_LAUNCH
17     APP_MEMORY=$(sdb shell "memps -v | grep 'Tizen.exe'" | tail -1)
18     MEMORY_PID=($(echo $APP_MEMORY | awk '{print $1}'))
19     MEMORY_PSS=($(echo $APP_MEMORY | awk '{print $7}'))
20     MEMORY_3D=($(echo $APP_MEMORY | awk '{print $8}'))
21     MEMORY_GEM=($(echo $APP_MEMORY | awk '{print $9}'))
22     APP_MEMORY=$(sdb shell "memps -v | grep 'Available'" | tail -1)
23     AFTER_MEMORY=($(echo $APP_MEMORY | awk '{print $5}'))
24     let MEMORY_FREE=$BEFORE_MEMORY-$AFTER_MEMORY
25     echo -e "PSS\t3D\tGEM\tFREE" | tee -a $RESULT_FILE
26     echo -e "$MEMORY_PSS\t$MEMORY_3D\t$MEMORY_GEM\t$MEMORY_FREE" | tee -a $RESULT_FILE
27     DETAIL_MEMORY=$(sdb shell "memps $MEMORY_PID" | while read line
28         do
29             DETAIL_MEMORY_LIST=$line
30             DETAIL_PCODE=($(echo $DETAIL_MEMORY_LIST | awk '{print $3}' | tr -d '\r'))
31             DETAIL_PDATA=($(echo $DETAIL_MEMORY_LIST | awk '{print $4}' | tr -d '\r'))
32             if [[ $DETAIL_PCODE != "P(CODE)" ]] && [[ $DETAIL_PDATA != "P(DATA)" ]] &&
33                [[ $DETAIL_PCODE != "--------" ]] && [[ $DETAIL_PDATA != "--------" ]]
34             then
35                 let DETAIL_SUM=$DETAIL_PCODE+$DETAIL_PDATA
36                 if [[ $DETAIL_SUM -ge 100 ]]
37                 then
38                     DETAIL_OBJECT=($(echo $DETAIL_MEMORY_LIST | awk '{print $6}'))
39                     echo -n "$DETAIL_SUM\t$DETAIL_OBJECT"
40                     echo ""
41                 fi
42             fi
43         done | sort -n -r | tr -d '\r'
44     )
45     echo -e "P(C+D)\tOBJECT NAME" | tee -a $RESULT_FILE
46     for item in ${DETAIL_MEMORY[*]}
47     do
48         echo -e $item | tee -a $RESULT_FILE
49     done
50     echo -e "" | tee -a $RESULT_FILE
51     sleep 3
52     sdb shell kill -9 $MEMORY_PID
53     sleep $WAIT_FOR_LAUNCH
54     echo -e "T(ms)\tAPP ID" | tee -a $RESULT_FILE
55     APP_MEMORY=$(sdb shell "memps -v | grep 'Available'" | tail -1)
56     BEFORE_MEMORY=($(echo $APP_MEMORY | awk '{print $5}'))
57 done