Introduce profiling feature on test_driver.sh (#1248)
author김용섭/동작제어Lab(SR)/Engineer/삼성전자 <yons.kim@samsung.com>
Thu, 17 May 2018 07:46:29 +0000 (16:46 +0900)
committer서상민/동작제어Lab(SR)/Senior Engineer/삼성전자 <sangmin7.seo@samsung.com>
Thu, 17 May 2018 07:46:29 +0000 (16:46 +0900)
Now `test_driver.sh --profile` runs profiling by `oprofile`. To profile,
`oprofile` should be installed on target machine and needs root
permission.

Signed-off-by: Yongseop Kim <yons.kim@samsung.com>
tools/test_driver/test_driver.sh

index ba32c96..bac009c 100755 (executable)
@@ -35,6 +35,9 @@ function Usage()
     echo "--benchmark           - (default=off) run benchmark"
     echo "--benchmark_acl       - (default=off) run benchmark-acl"
     echo ""
+    echo "Following option is used for profiling."
+    echo "--profile             - (default=off) run operf"
+    echo ""
     echo "etc."
     echo "--framework_driverbin           - (default=../../Product/out/bin/tflite_run) runner for runnning framework tests"
     echo "--verification_driverbin        - (default=../../Product/out/bin/nnapi_test) runner for runnning verification tests"
@@ -65,6 +68,7 @@ VERIFICATION_ON="false"
 BENCHMARK_ON="false"
 BENCHMARK_ACL_ON="false"
 ACL_ENV_ON="false"
+PROFILE_ON="false"
 
 for i in "$@"
 do
@@ -123,6 +127,10 @@ do
         --acl_envon)
             ACL_ENV_ON="true"
             ;;
+        --profile)
+            ALLTEST_ON="false"
+            PROFILE_ON="true"
+            ;;
         *)
             # Be careful that others params are handled as $ARTIFACT_PATH
             ARTIFACT_PATH="$i"
@@ -233,3 +241,19 @@ if [ "$BENCHMARK_ON" == "true" ] || [ "$BENCHMARK_ACL_ON" == "true" ]; then
     source $ARTIFACT_PATH/tools/test_driver/print_to_json.sh
     print_to_json $ARTIFACT_PATH/report/benchmark $ARTIFACT_PATH/report
 fi
+
+# Run profiling
+if [ "$PROFILE_ON" == "true" ]; then
+    # FIXME: These driver and tflite test are set temporarily. Fix these to support flexibility
+    DRIVER_BIN=$ARTIFACT_PATH/Product/out/bin/tflite_run
+    TFLITE_TEST=$ARTIFACT_PATH/tests/framework/cache/inceptionv3/inception_module/inception_test.tflite
+
+    # TODO: Enable operf to set directory where sample data puts on
+    rm -rf oprofile_data
+
+    echo ""
+    echo "============================================"
+    operf -g $DRIVER_BIN $TFLITE_TEST
+    echo "============================================"
+    echo ""
+fi