Add tool option for check launching memory
[platform/core/dotnet/launcher.git] / tools / performance_test.sh
index fa42f79..370f425 100755 (executable)
@@ -60,33 +60,30 @@ install_tpk ()
 
     for item in ${TPKS[*]}
     do
-#        INSTALL_MSG=$(sdb install tpk/$item | grep start)
-#        INSTALL_MSG=$(echo $INSTALL_MSG | sed "s/\[/ /g")
-#        INSTALL_MSG=$(echo $INSTALL_MSG | sed "s/\]/ /g")
-#        PKG_IDS+=($(echo $INSTALL_MSG | awk '{print $7}'))
-        INSTALL_PKG=$(sdb install tpk/$item | grep start  | sed "s/\[/ /g" | sed "s/\]/ /g" | awk '{print $7}' | tr -d '\r')
-        PKG_IDS+=$INSTALL_PKG
-        #($(echo $INSTALL_PKG)
-        echo " [>]  $INSTALL_PKG installs complete"
+        INSTALL_MSG=$(sdb install tpk/$item | grep start)
+        INSTALL_MSG=$(echo $INSTALL_MSG | sed "s/\[/ /g")
+        INSTALL_MSG=$(echo $INSTALL_MSG | sed "s/\]/ /g")
+        PKG_IDS+=($(echo $INSTALL_MSG | awk '{print $7}' | tr -d '\r'))
+        echo " [>] ($(echo $INSTALL_MSG | awk '{print $7}')) installs complete"
     done
 }
 
 get_current_tpk_apps ()
 {
     echo "[>] Get application list in device"
-    PKG_IDS+=$(
-        sdb shell "su - owner -c 'pkgcmd -l | grep tpk'" |  while read line
-        do
-            APP_LIST_ENTITY=$line
-            APP_LIST_ENTITY=$(echo $APP_LIST_ENTITY | sed "s/\[/ /g")
-            APP_LIST_ENTITY=$(echo $APP_LIST_ENTITY | sed "s/\]/ /g")
-            APP_OWNER=($(echo $APP_LIST_ENTITY | awk '{print $1}'))
-            if [[ $APP_OWNER == 'user' ]]
-            then
-                echo $APP_LIST_ENTITY | awk '{print $6}'
-            fi
-        done | sort | tr -d '\r'
-    )
+#    PKG_IDS+=$(
+#        sdb shell "su - owner -c 'pkgcmd -l | grep tpk'" |  while read line
+#        do
+#            APP_LIST_ENTITY=$line
+#            APP_LIST_ENTITY=$(echo $APP_LIST_ENTITY | sed "s/\[/ /g")
+#            APP_LIST_ENTITY=$(echo $APP_LIST_ENTITY | sed "s/\]/ /g")
+#            APP_OWNER=($(echo $APP_LIST_ENTITY | awk '{print $1}'))
+#            if [[ $APP_OWNER == 'user' ]]
+#            then
+#                echo $APP_LIST_ENTITY | awk '{print $6}'
+#            fi
+#        done | sort | tr -d '\r'
+#    )
 #In 3.0 mobile / wearable, appfw install all of application to global application
     PKG_IDS+=$(
         sdb shell "su - owner -c 'ls -al /opt/usr/globalapps/ | grep tizenglobalapp'" |  while read line
@@ -131,7 +128,7 @@ initialize_first_launch ()
 execute_time_stamp_auto ()
 {
     echo ""
-    echo "[>] Start performance test that applciation launching "
+    echo "[>] Start performance test that applciation launching time"
     echo ""
 #execute dlogstreamer
     sdb shell "dlogutil -c"
@@ -142,11 +139,27 @@ execute_time_stamp_auto ()
     TIMESTAMP_PID=$!
 }
 
+execute_time_stamp_auto_memory ()
+{
+    echo ""
+    echo "[>] Start performance test that applciation launching memory"
+    echo ""
+    sdb shell "dlogutil -c"
+    sdb shell "dlogutil -v time AUL APP_CORE|grep -E 'app_request_to_launchpad_for_uid.*[SECURE_LOG].*launch.*request|__show_cb.*[EVENT_TEST][EVENT]'" >> $STREAM_LOG_FILE &
+    DLOG_STREAMER_PID=$!
+#execute timestamp
+    /bin/bash ./timestamp.sh $STREAM_LOG_FILE $RESULT_LOG_FILE &
+    TIMESTAMP_PID=$!
+#execute memorystamp
+    /bin/bash ./memorystamp.sh $STREAM_LOG_FILE $RESULT_LOG_FILE &
+    MEMORYSTAMP_PID=$!
+}
+
 execute_time_stamp_manual ()
 {
 #execute dlogstreamer
     echo ""
-    echo "[>] Start performance test that applciation launching "
+    echo "[>] Start performance test that applciation launching time"
     echo ""
     rm $STREAM_LOG_FILE
     touch $STREAM_LOG_FILE
@@ -163,7 +176,7 @@ execute_time_stamp_manual_trace ()
 {
 #execute dlogstreamer
     echo ""
-    echo "[>] Start performance test that applciation launching "
+    echo "[>] Start performance test that applciation launching time"
     echo ""
     rm $STREAM_LOG_FILE
     touch $STREAM_LOG_FILE
@@ -181,6 +194,25 @@ execute_time_stamp_manual_trace ()
     rm result/*.raw
 }
 
+execute_time_stamp_manual_memory ()
+{
+    echo ""
+    echo "[>] Start performance test that applciation launching memory"
+    echo ""
+    rm $STREAM_LOG_FILE
+    touch $STREAM_LOG_FILE
+    sdb shell "dlogutil -c"
+    sdb shell "dlogutil -v time AUL APP_CORE|grep -E 'app_request_to_launchpad_for_uid.*[SECURE_LOG].*launch.*request|__show_cb.*[EVENT_TEST][EVENT]'" >> $STREAM_LOG_FILE &
+    DLOG_STREAMER_PID=$!
+#execute timestamp
+    /bin/bash ./timestamp.sh $STREAM_LOG_FILE $RESULT_LOG_FILE &
+    TIMESTAMP_PID=$!
+#execute memorystamp
+    /bin/bash ./memorystamp.sh $STREAM_LOG_FILE $RESULT_LOG_FILE &
+    MEMORYSTAMP_PID=$!
+    wait $MEMORYSTAMP_PID
+}
+
 execute_all_app ()
 {
 #execute each apps
@@ -206,7 +238,11 @@ execute_all_app_trace ()
         TTRACE_PID=$!
         sleep 1
         APP_LIST_MSG=$(sdb shell "su - owner -c 'app_launcher -s $item'")
+        if [[ "${LONG_LAUNCHING_APP[@]}" =~ "${item}" ]]; then
+            sleep $WAIT_FOR_LONG_LAUNCH
+        else
         sleep $WAIT_FOR_LAUNCH
+        fi
         APP_LIST_MSG=$(sdb shell "su - owner -c 'app_launcher -t $item'")
         sleep $WAIT_FOR_KILL
         sleep 4
@@ -215,6 +251,24 @@ execute_all_app_trace ()
     rm result/*.raw
 }
 
+execute_all_app_memory ()
+{
+    sleep $WAIT_FOR_LAUNCH
+#execute each apps
+    for item in ${APP_IDS[*]}
+    do
+        if [[ "${LONG_LAUNCHING_APP[@]}" =~ "${item}" ]]; then
+            echo ""
+        else
+            APP_LIST_MSG=$(sdb shell "su - owner -c 'app_launcher -s $item'")
+            sleep $WAIT_FOR_LONG_LAUNCH
+            #APP_LIST_MSG=$(sdb shell "su - owner -c 'app_launcher -t $item'")
+            sleep $WAIT_FOR_KILL
+        fi
+        sleep $WAIT_FOR_LONG_LAUNCH
+    done
+}
+
 finalize ()
 {
     echo ""
@@ -231,6 +285,7 @@ destory ()
     kill -9 $DLOG_STREAMER_PID>/dev/null 2>&1
     kill -9 $TIMESTAMP_PID>/dev/null 2>&1
     kill -9 $TTRACE_PID>/dev/null 2>&1
+    kill -9 $MEMORYSTAMP_PID>/dev/null 2>&1
     rm $STREAM_LOG_FILE>/dev/null 2>&1
     sdb shell "devicectl display start">/dev/null 2>&1
     echo "[>] Finalize for Performance Test"
@@ -241,11 +296,13 @@ help ()
 {
     echo ""
     echo "[!] usage   : <script> [option]"
-    echo "    options : -a --auto    full automatic test"
+    echo "    options : -a --auto             full automatic launching time test"
     echo "            : (suboption for auto) -s --skip-install  skip install tpk (execute tpk app in device)"
-    echo "            : -m --manual  execute application manually "
-    echo "            : -ta --ttrace-auto     full automatic test with ttrace"
-    echo "            : -tm --ttrace-manual   execute only one application manually with ttrace"
+    echo "            : -m --manual           execute application manually"
+    echo "            : -am --auto-memory     full automatic launching memory test"
+    echo "            : -mm --manual-memory   execute application manually with memory test"
+    echo "            : -at --auto-ttrace     full automatic launching time test with ttrace"
+    echo "            : -mt --manual-ttrace   execute application manually with ttrace"
     echo "example : ./performance_test.sh --auto"
     echo ""
 }
@@ -269,7 +326,7 @@ then
     execute_time_stamp_auto
     execute_all_app
     finalize
-elif [[ $1 == '-m' ]] || [[ $1 == "--manual" ]]
+elif [[ $1 == "-m" ]] || [[ $1 == "--manual" ]]
 then
     echo ""
     echo "[>] Start with MANUAL mode"
@@ -277,7 +334,30 @@ then
     initialize
     execute_time_stamp_manual
     finalize
-elif [[ $1 == '-ta' ]] || [[ $1 == "--ttrace-auto" ]]
+elif [[ $1 == "-am" ]] || [[ $1 == "--auto-memory" ]]
+then
+    echo ""
+    echo "[>] Launching Memory Profiling with AUTO mode"
+    initialize
+    if [[ $2 == "-s" ]] || [[ $2 == "--skip-install" ]]
+    then
+        get_current_tpk_apps
+    else
+        install_tpk
+    fi
+    make_appid_list
+    initialize_first_launch
+    execute_time_stamp_auto_memory
+    execute_all_app_memory
+    finalize
+elif [[ $1 == "-mm" ]] || [[ $1 == "--manual-memory" ]]
+then
+    echo ""
+    echo "[>] Launching Memory Profiling with MANUAL mode"
+    initialize
+    execute_time_stamp_manual_memory
+    finalize
+elif [[ $1 == "-at" ]] || [[ $1 == "--auto-ttrace" ]]
 then
     echo ""
     echo "[>] Start with T-trace Auto mode"
@@ -293,7 +373,7 @@ then
     execute_time_stamp_auto
     execute_all_app_trace
     finalize
-elif [[ $1 == '-tm' ]] || [[ $1 == "--ttrace-manual" ]]
+elif [[ $1 == "-mt" ]] || [[ $1 == "--manual-ttrace" ]]
 then
     echo ""
     echo "[>] Start with T-trace Manual mode"
@@ -303,4 +383,4 @@ then
     finalize
 else
     help
-fi
\ No newline at end of file
+fi