3 STREAM_LOG_FILE=stream.log
4 DATE=$(date +%Y%m%d_%H%M)
5 RESULT_LOG_FILE='result/result_'$DATE'.log'
8 WAIT_FOR_LONG_LAUNCH=30
15 "org.tizen.example.SNSUI.Tizen",
21 echo "[>] Initialize for Performance Test"
22 if [ $(sdb get-state 2>/dev/null | grep -c "device") -eq 0 ];
25 echo "[!] device is not connected - cannot execute"
30 if [ $(dpkg-query -W -f='${Status}' inotify-tools 2>/dev/null | grep -c "ok installed") -eq 0 ];
33 echo "[!] inotify-tools package should install"
34 echo "[!] starting install inotify-tools .. "
35 sudo apt-get install inotify-tools
36 if [ $(dpkg-query -W -f='${Status}' inotify-tools 2>/dev/null | grep -c "ok installed") -eq 0 ];
39 echo "[!] install inotify-tools fail - cannot execute"
43 echo 32768 | sudo tee /proc/sys/fs/inotify/max_user_watches
44 echo fs.inotify.max_user_watches=32768 | sudo tee -a /etc/sysctl.conf
48 sdb shell "devicectl display stop">/dev/null 2>&1
49 mkdir result>/dev/null 2>&1
50 rm $STREAM_LOG_FILE>/dev/null 2>&1
51 touch $STREAM_LOG_FILE
57 echo "[>] Installing package in tpk directory"
58 TPKS=($(ls tpk | grep .tpk))
61 for item in ${TPKS[*]}
63 INSTALL_MSG=$(sdb install tpk/$item | grep start)
64 INSTALL_MSG=$(echo $INSTALL_MSG | sed "s/\[/ /g")
65 INSTALL_MSG=$(echo $INSTALL_MSG | sed "s/\]/ /g")
66 PKG_IDS+=($(echo $INSTALL_MSG | awk '{print $7}' | tr -d '\r'))
67 echo " [>] ($(echo $INSTALL_MSG | awk '{print $7}')) installs complete"
71 get_current_tpk_apps ()
73 echo "[>] Get application list in device"
75 # sdb shell "su - owner -c 'pkgcmd -l | grep tpk'" | while read line
77 # APP_LIST_ENTITY=$line
78 # APP_LIST_ENTITY=$(echo $APP_LIST_ENTITY | sed "s/\[/ /g")
79 # APP_LIST_ENTITY=$(echo $APP_LIST_ENTITY | sed "s/\]/ /g")
80 # APP_OWNER=($(echo $APP_LIST_ENTITY | awk '{print $1}'))
81 # if [[ $APP_OWNER == 'user' ]]
83 # echo $APP_LIST_ENTITY | awk '{print $6}'
85 # done | sort | tr -d '\r'
87 #In 3.0 mobile / wearable, appfw install all of application to global application
89 sdb shell "su - owner -c 'ls -al /opt/usr/globalapps/ | grep tizenglobalapp'" | while read line
92 APP_GLOBAL=($(echo $APP_LIST_ENTITY | awk '{print $3}'))
93 if [[ $APP_GLOBAL == 'tizenglobalapp' ]]
95 echo $APP_LIST_ENTITY | awk '{print $9}'
97 done | sort | tr -d '\r'
104 echo "[>] Get application id that installed"
105 for item in ${PKG_IDS[*]}
107 APP_LIST_MSG=$(sdb shell "su - owner -c 'pkginfo --pkg $item' | grep mainappid" | tail -1)
108 APP_IDS+=($(echo $APP_LIST_MSG | awk '{print $3}' | tr -d '\r'))
112 initialize_first_launch ()
114 if [[ -z ${APP_IDS[0]} ]]; then
116 echo "[!] No tpk Packages for test"
117 echo "[!] Copy tpk files in [./tpk] directory"
121 echo "[>] Initial launch an application"
122 APP_LIST_MSG=$(sdb shell "su - owner -c 'app_launcher -s ${APP_IDS[0]}'")
124 APP_LIST_MSG=$(sdb shell "su - owner -c 'app_launcher -t ${APP_IDS[0]}'")
128 execute_time_stamp_auto ()
131 echo "[>] Start performance test that applciation launching time"
133 #execute dlogstreamer
134 sdb shell "dlogutil -c"
135 sdb shell "dlogutil -v time AUL LAUNCH|grep -E 'launch.*app_request_to_launchpad_for_uid.*request.*appid|Launching:done'" >> $STREAM_LOG_FILE &
138 /bin/bash ./timestamp.sh $STREAM_LOG_FILE $RESULT_LOG_FILE &
142 execute_time_stamp_auto_memory ()
145 echo "[>] Start performance test that applciation launching memory"
147 sdb shell "dlogutil -c"
148 sdb shell "dlogutil -v time AUL LAUNCH|grep -E 'launch.*app_request_to_launchpad_for_uid.*request.*appid|Launching:done'" >> $STREAM_LOG_FILE &
151 /bin/bash ./timestamp.sh $STREAM_LOG_FILE $RESULT_LOG_FILE &
154 /bin/bash ./memorystamp.sh $STREAM_LOG_FILE $RESULT_LOG_FILE &
158 execute_time_stamp_manual ()
160 #execute dlogstreamer
162 echo "[>] Start performance test that applciation launching time"
165 touch $STREAM_LOG_FILE
166 sdb shell "dlogutil -c"
167 sdb shell "dlogutil -v time AUL LAUNCH|grep -E 'launch.*app_request_to_launchpad_for_uid.*request.*appid|Launching:done'" >> $STREAM_LOG_FILE &
170 /bin/bash ./timestamp.sh $STREAM_LOG_FILE $RESULT_LOG_FILE
175 execute_time_stamp_manual_trace ()
177 #execute dlogstreamer
179 echo "[>] Start performance test that applciation launching time"
182 touch $STREAM_LOG_FILE
183 sdb shell "dlogutil -c"
184 sdb shell "dlogutil -v time AUL LAUNCH|grep -E 'launch.*app_request_to_launchpad_for_uid.*request.*appid|Launching:done'" >> $STREAM_LOG_FILE &
187 /bin/bash ./timestamp.sh $STREAM_LOG_FILE $RESULT_LOG_FILE &
190 ~/tizen-sdk/tools/ttrace/ttrace.py -b 20480 -t 10 -o result/trace.html idle app view am &
197 execute_time_stamp_manual_memory ()
200 echo "[>] Start performance test that applciation launching memory"
203 touch $STREAM_LOG_FILE
204 sdb shell "dlogutil -c"
205 sdb shell "dlogutil -v time AUL LAUNCH|grep -E 'launch.*app_request_to_launchpad_for_uid.*request.*appid|Launching:done'" >> $STREAM_LOG_FILE &
208 /bin/bash ./timestamp.sh $STREAM_LOG_FILE $RESULT_LOG_FILE &
211 /bin/bash ./memorystamp.sh $STREAM_LOG_FILE $RESULT_LOG_FILE &
213 wait $MEMORYSTAMP_PID
219 for item in ${APP_IDS[*]}
221 APP_LIST_MSG=$(sdb shell "su - owner -c 'app_launcher -s $item'")
222 if [[ "${LONG_LAUNCHING_APP[@]}" =~ "${item}" ]]; then
223 sleep $WAIT_FOR_LONG_LAUNCH
225 sleep $WAIT_FOR_LAUNCH
227 APP_LIST_MSG=$(sdb shell "su - owner -c 'app_launcher -t $item'")
232 execute_all_app_trace ()
235 for item in ${APP_IDS[*]}
237 ~/tizen-sdk/tools/ttrace/ttrace.py -b 20480 -t 13 -o result/${item}.html idle app view am & > /dev/null 2>&1
240 APP_LIST_MSG=$(sdb shell "su - owner -c 'app_launcher -s $item'")
241 if [[ "${LONG_LAUNCHING_APP[@]}" =~ "${item}" ]]; then
242 sleep $WAIT_FOR_LONG_LAUNCH
244 sleep $WAIT_FOR_LAUNCH
246 APP_LIST_MSG=$(sdb shell "su - owner -c 'app_launcher -t $item'")
254 execute_all_app_memory ()
256 sleep $WAIT_FOR_LAUNCH
258 for item in ${APP_IDS[*]}
260 if [[ "${LONG_LAUNCHING_APP[@]}" =~ "${item}" ]]; then
263 APP_LIST_MSG=$(sdb shell "su - owner -c 'app_launcher -s $item'")
264 sleep $WAIT_FOR_LONG_LAUNCH
265 #APP_LIST_MSG=$(sdb shell "su - owner -c 'app_launcher -t $item'")
268 sleep $WAIT_FOR_LONG_LAUNCH
279 echo "[>] Result file : [ $RESULT_LOG_FILE ]"
285 kill -9 $DLOG_STREAMER_PID>/dev/null 2>&1
286 kill -9 $TIMESTAMP_PID>/dev/null 2>&1
287 kill -9 $TTRACE_PID>/dev/null 2>&1
288 kill -9 $MEMORYSTAMP_PID>/dev/null 2>&1
289 rm $STREAM_LOG_FILE>/dev/null 2>&1
290 sdb shell "devicectl display start">/dev/null 2>&1
291 echo "[>] Finalize for Performance Test"
298 echo "[!] usage : <script> [option]"
299 echo " options : -a --auto full automatic launching time test"
300 echo " : (suboption for auto) -s --skip-install skip install tpk (execute tpk app in device)"
301 echo " : -m --manual execute application manually"
302 echo " : -am --auto-memory full automatic launching memory test"
303 echo " : -mm --manual-memory execute application manually with memory test"
304 echo " : -at --auto-ttrace full automatic launching time test with ttrace"
305 echo " : -mt --manual-ttrace execute application manually with ttrace"
306 echo "example : ./performance_test.sh --auto"
313 if [[ $1 == '-a' ]] || [[ $1 == "--auto" ]]
316 echo "[>] Start with AUTO mode"
318 if [[ $2 == "-s" ]] || [[ $2 == "--skip-install" ]]
325 initialize_first_launch
326 execute_time_stamp_auto
329 elif [[ $1 == "-m" ]] || [[ $1 == "--manual" ]]
332 echo "[>] Start with MANUAL mode"
333 echo "[>] execute installed application in your device"
335 execute_time_stamp_manual
337 elif [[ $1 == "-am" ]] || [[ $1 == "--auto-memory" ]]
340 echo "[>] Launching Memory Profiling with AUTO mode"
342 if [[ $2 == "-s" ]] || [[ $2 == "--skip-install" ]]
349 initialize_first_launch
350 execute_time_stamp_auto_memory
351 execute_all_app_memory
353 elif [[ $1 == "-mm" ]] || [[ $1 == "--manual-memory" ]]
356 echo "[>] Launching Memory Profiling with MANUAL mode"
358 execute_time_stamp_manual_memory
360 elif [[ $1 == "-at" ]] || [[ $1 == "--auto-ttrace" ]]
363 echo "[>] Start with T-trace Auto mode"
365 if [[ $2 == "-s" ]] || [[ $2 == "--skip-install" ]]
372 initialize_first_launch
373 execute_time_stamp_auto
374 execute_all_app_trace
376 elif [[ $1 == "-mt" ]] || [[ $1 == "--manual-ttrace" ]]
379 echo "[>] Start with T-trace Manual mode"
380 echo "[>] execute installed application in your device"
382 execute_time_stamp_manual_trace