diff options
-rwxr-xr-x | tools/README | 95 | ||||
-rwxr-xr-x | tools/performance_test.sh | 285 | ||||
-rwxr-xr-x | tools/timestamp.sh | 56 |
3 files changed, 436 insertions, 0 deletions
diff --git a/tools/README b/tools/README new file mode 100755 index 0000000..41e934b --- /dev/null +++ b/tools/README @@ -0,0 +1,95 @@ +README file for performance test of dotnet launcher + + +[*] SUMMARY +------------------------------------------------------------------------------- +Performance test is a tool to calcuate launching time. +This tool is performed on the host where the device is connected with sdb + +[*] PREPARATIONS +------------------------------------------------------------------------------- +The test consists of two files. + - performance_test.sh : main executable script + - timestamp.sh : used by "performance_test.sh" +The files should be in the same directory in host. + +For running automatic test, you have to locate ".tpk" files in specific directory +More detail, it describes in "USAGE" section. + +This test need below package + - inotify-tools +If the package is not exist, it will try to install the package. + +The host can connect device with sdb. + + +[*] TEST MODES +------------------------------------------------------------------------------- +There are two modes in performance test + - auto test mode + - manual test mode + +Each mode has the following characteristics. +[Auto test mode] + This mode automatically installs applications and measures and records performance. + This mode need ".tpk" packaged dotnet application. It should located in "tpk" directory. + So, files locates likes below. + . + ├── performance_test.sh + ├── README + ├── timestamp.sh + └── tpk + └── <tpk_application_file_name>.tpk + There can be several tpk files. And tpk files can be freely added or deleted by the user. +[Manual test mode] + This mode measures the execution time when the user executes the installed applications. + After executing this mode, the user runs and terminates the application. + And then, result of launching time and making report file. + + +[*] USAGE +------------------------------------------------------------------------------- +The test has two modes. + - automatic test + - manual test + +Each test can be run through shell below options. + -a --auto : execute automatic test + -m --manual : execute manual test + +In the auto test mode does not require user input. +In the manual test mode, the user executes / terminates the application after executing the test. + + +[*] TEST RESULT +------------------------------------------------------------------------------- +Test results are generated as files in the "result/" directory. +The resulting file name is determined by the date and time, likes "result/result_YYYYMMDD_HHmm.log" + +Test results consist of launching time(ms) and applicatoin id. +example of result : + T(ms) APP ID + 680 org.tizen.example.BasicSampleXamarine.Tizen + 710 org.tizen.example.XamarinApplication1.Tizen + 1460 org.tizen.example.EmailUI.Tizen + 770 org.tizen.example.FormsTizenGallery.Tizen + 2390 org.tizen.example.SNSUI.Tizen + + +[*] ERROR CASE +------------------------------------------------------------------------------- +Some system can be occur error with some points. +In this section, we would like to share some solutions to solve the problems. + +[>] Inotify-tools - 'max_user_watchers' error + + [ERROR CASE] + Failed to watch stream.log; upper limit on inotify watches reached! + Please increase the amount of inotify watches allowed per user via `/proc/sys/fs/inotify/max_user_watches'. + + execute below command for expand max_user_watchers for inotify-tool + + [SOLVE] + echo 32768 | sudo tee /proc/sys/fs/inotify/max_user_watches + echo fs.inotify.max_user_watches=32768 | sudo tee -a /etc/sysctl.conf + sudo sysctl -p diff --git a/tools/performance_test.sh b/tools/performance_test.sh new file mode 100755 index 0000000..def3105 --- /dev/null +++ b/tools/performance_test.sh @@ -0,0 +1,285 @@ +#!/bin/bash + +STREAM_LOG_FILE=stream.log +DATE=$(date +%Y%m%d_%H%M) +RESULT_LOG_FILE='result/result_'$DATE'.log' + +WAIT_FOR_LAUNCH=10 +WAIT_FOR_KILL=5 + +PKG_IDS=() +APP_IDS=() + +initialize () +{ + echo "" + echo "[>] Initialize for Performance Test" + if [ $(sdb get-state 2>/dev/null | grep -c "device") -eq 0 ]; + then + echo "" + echo "[!] device is not connected - cannot execute" + echo "" + exit 0 + fi + + if [ $(dpkg-query -W -f='${Status}' inotify-tools 2>/dev/null | grep -c "ok installed") -eq 0 ]; + then + echo "" + echo "[!] inotify-tools package should install" + echo "[!] starting install inotify-tools .. " + sudo apt-get install inotify-tools + if [ $(dpkg-query -W -f='${Status}' inotify-tools 2>/dev/null | grep -c "ok installed") -eq 0 ]; + then + echo "" + echo "[!] install inotify-tools fail - cannot execute" + echo "" + exit 0 + fi + echo 32768 | sudo tee /proc/sys/fs/inotify/max_user_watches + echo fs.inotify.max_user_watches=32768 | sudo tee -a /etc/sysctl.conf + sudo sysctl -p + fi + sdb root on + sdb shell "devicectl display stop">/dev/null 2>&1 + mkdir result>/dev/null 2>&1 + rm $STREAM_LOG_FILE>/dev/null 2>&1 + touch $STREAM_LOG_FILE +} + +install_tpk () +{ +#install tpk packages + echo "[>] Installing package in tpk directory" + TPKS=($(ls tpk | grep .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}')) + 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 + ) +} + +make_appid_list () +{ +#get app ids + echo "[>] Get application id that installed" + for item in ${PKG_IDS[*]} + do + APP_LIST_MSG=$(sdb shell "su - owner -c 'app_launcher -l | grep $item'") + APP_LIST_MSG=${APP_LIST_MSG#*\'} + APP_LIST_MSG=$(echo $APP_LIST_MSG | sed "s/'/ /g") + APP_IDS+=($(echo $APP_LIST_MSG | awk '{print $2}')) + done +} + +initialize_first_launch () +{ + if [[ -z ${APP_IDS[0]} ]]; then + echo "" + echo "[!] No tpk Packages for test" + echo "[!] Copy tpk files in [./tpk] directory" + echo "" + exit 0 + fi + echo "[>] Initial launch an application" + APP_LIST_MSG=$(sdb shell "su - owner -c 'app_launcher -s ${APP_IDS[0]}'") + sleep 10 + APP_LIST_MSG=$(sdb shell "su - owner -c 'app_launcher -k ${APP_IDS[0]}'") + sleep 5 +} + +execute_time_stamp_auto () +{ + echo "" + echo "[>] Start performance test that applciation launching " + echo "" +#execute dlogstreamer + 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_time_stamp_manual () +{ +#execute dlogstreamer + echo "" + echo "[>] Start performance test that applciation launching " + 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=$! + wait $TIMESTAMP_PID +} + +execute_time_stamp_manual_trace () +{ +#execute dlogstreamer + echo "" + echo "[>] Start performance test that applciation launching " + 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 ttrace + ~/tizen-sdk/tools/ttrace/ttrace.py -b 20480 -t 10 -o result/trace.html idle app view am & + TTRACE_PID=$! + wait $TTRACE_PID + rm result/*.ftrace + rm result/*.raw +} + +execute_all_app () +{ +#execute each apps + for item in ${APP_IDS[*]} + do + APP_LIST_MSG=$(sdb shell "su - owner -c 'app_launcher -s $item'") + sleep $WAIT_FOR_LAUNCH + APP_LIST_MSG=$(sdb shell "su - owner -c 'app_launcher -k $item'") + sleep $WAIT_FOR_KILL + done +} + +execute_all_app_trace () +{ +#execute each apps + for item in ${APP_IDS[*]} + do + ~/tizen-sdk/tools/ttrace/ttrace.py -b 20480 -t 13 -o result/${item}.html idle app view am & > /dev/null 2>&1 + TTRACE_PID=$! + sleep 1 + APP_LIST_MSG=$(sdb shell "su - owner -c 'app_launcher -s $item'") + sleep $WAIT_FOR_LAUNCH + APP_LIST_MSG=$(sdb shell "su - owner -c 'app_launcher -t $item'") + sleep $WAIT_FOR_KILL + sleep 4 + done + rm result/*.ftrace + rm result/*.raw +} + +finalize () +{ + echo "" + echo "[>] Result" + echo "" + cat $RESULT_LOG_FILE + echo "" + echo "[>] Result file : [ $RESULT_LOG_FILE ]" +} + +destory () +{ + echo "" + 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 + rm $STREAM_LOG_FILE>/dev/null 2>&1 + sdb shell "devicectl display start">/dev/null 2>&1 + echo "[>] Finalize for Performance Test" + echo "" +} + +help () +{ + echo "" + echo "[!] usage : <script> [option]" + echo " options : -a --auto full automatic 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 "example : ./performance_test.sh --auto" + echo "" +} + + +trap "destory" 0 + +if [[ $1 == '-a' ]] || [[ $1 == "--auto" ]] +then + echo "" + echo "[>] Start 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 + execute_all_app + finalize +elif [[ $1 == '-m' ]] || [[ $1 == "--manual" ]] +then + echo "" + echo "[>] Start with MANUAL mode" + echo "[>] execute installed application in your device" + initialize + execute_time_stamp_manual + finalize +elif [[ $1 == '-ta' ]] || [[ $1 == "--ttrace-auto" ]] +then + echo "" + echo "[>] Start with T-trace 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 + execute_all_app_trace + finalize +elif [[ $1 == '-tm' ]] || [[ $1 == "--ttrace-manual" ]] +then + echo "" + echo "[>] Start with T-trace Manual mode" + echo "[>] execute installed application in your device" + initialize + execute_time_stamp_manual_trace + finalize +else + help +fi + diff --git a/tools/timestamp.sh b/tools/timestamp.sh new file mode 100755 index 0000000..57923a7 --- /dev/null +++ b/tools/timestamp.sh @@ -0,0 +1,56 @@ +#!/bin/bash + +if [[ -z $1 ]] || [[ -z $2 ]] +then + echo "[!] Execute [./performance_test.sh]" + exit 0 +fi + +LOG_FILE=$1 +RESULT_FILE=$2 + +IS_START=false +echo -e "T(ms)\tAPP ID" | tee -a $RESULT_FILE +while inotifywait -qqre modify "$LOG_FILE"; do + GET_LOG="$(tail -1 $LOG_FILE)" + GET_LOG=$(echo $GET_LOG | sed "s/(/ /g") + if [[ $GET_LOG == *"app_request_to_launchpad_for_uid"* ]]; + then + APP_NAME=$(echo "$GET_LOG" | grep app_request_to_launchpad_for_uid | awk '{print $13}') + APP_NAME=$(echo $APP_NAME | tr -d '\r') + IS_DIGIT=$(echo $APP_NAME | sed "s/[^0-9]*//g") + + if [[ $IS_DIGIT != $APP_NAME ]]; + then + START_T=$(echo "$GET_LOG" | grep app_request_to_launchpad_for_uid | awk '{print $2}') + START_T=${START_T%%+0900} + START_T=$(echo $START_T | sed "s/:/./g") + IS_START=true + fi + fi + + if [[ $GET_LOG == *APP_CORE* ]] && [ "$IS_START" = true ] + then + END_T=$(echo "$GET_LOG" | grep SHOW | awk '{print $2}') + END_T=${END_T%%+0900} + END_T=$(echo $END_T | sed "s/:/./g") + + IFS=. read -ra START_ARR <<<"$START_T" + START_MS=0 + : $[ START_MS = 10#$START_MS + 10#${START_ARR[0]} * 3600 * 1000 ] + : $[ START_MS = 10#$START_MS + 10#${START_ARR[1]} * 60 * 1000 ] + : $[ START_MS = 10#$START_MS + 10#${START_ARR[2]} * 1000 ] + : $[ START_MS = 10#$START_MS + 10#${START_ARR[3]} ] + + IFS=. read -ra END_ARR <<<"$END_T" + END_MS=0 + : $[ END_MS = 10#$END_MS + 10#${END_ARR[0]} * 3600 * 1000 ] + : $[ END_MS = 10#$END_MS + 10#${END_ARR[1]} * 60 * 1000 ] + : $[ END_MS = 10#$END_MS + 10#${END_ARR[2]} * 1000 ] + : $[ END_MS = 10#$END_MS + 10#${END_ARR[3]} ] + + : $[ DIFF_MS = $END_MS - $START_MS ] + echo -e "$DIFF_MS\t$APP_NAME" | tee -a $RESULT_FILE + IS_START=false + fi +done |