benchmark.sh 1.3 KB
Newer Older
Y
Yan Chunwei 已提交
1 2 3
#!/bin/bash
set -e

4
if [ $# -lt  3 ];
Y
Yan Chunwei 已提交
5 6 7
then
    echo "Input error"
    echo "USAGE:"
8 9
    echo "  sh benchmark.sh benchmark_bin_path benchmark_models_path result_filename"
    echo "  sh benchmark.sh benchmark_bin_path benchmark_models_path result_filename is_run_model_optimize"
Y
Yan Chunwei 已提交
10 11 12 13 14 15
    exit
fi

ANDROID_DIR=/data/local/tmp
WARMUP=10
REPEATS=30
J
juncaipeng 已提交
16 17
BENCHMARK_BIN=$1
MODELS_DIR=$2
18
RESULT_FILENAME=$3
J
juncaipeng 已提交
19
IS_RUN_MODEL_OPTIMIZE=false
20
if [ $# -gt  3 ];
J
juncaipeng 已提交
21
then
22
    IS_RUN_MODEL_OPTIMIZE=$4
J
juncaipeng 已提交
23
fi
Y
Yan Chunwei 已提交
24 25 26 27 28 29 30 31

adb push $BENCHMARK_BIN $ANDROID_DIR/benchmark_bin
adb shell chmod 777 $ANDROID_DIR/benchmark_bin
adb push $MODELS_DIR $ANDROID_DIR

adb shell "echo  PaddleLite Benchmark > $ANDROID_DIR/$RESULT_FILENAME"
for threads in 1 2 4
do
J
juncaipeng 已提交
32
adb shell "echo Threads=$threads Warmup=$WARMUP Repeats=$REPEATS  >>  $ANDROID_DIR/$RESULT_FILENAME"
Y
Yan Chunwei 已提交
33 34
for model_name in `ls $MODELS_DIR`
do
35
  echo "Model=$model_name Threads=$threads"
J
juncaipeng 已提交
36
  adb shell "$ANDROID_DIR/benchmark_bin --model_dir=$ANDROID_DIR/${MODELS_DIR##*/}/$model_name --warmup=$WARMUP --repeats=$REPEATS --threads=$threads --result_filename=$ANDROID_DIR/$RESULT_FILENAME --run_model_optimize=$IS_RUN_MODEL_OPTIMIZE"
Y
Yan Chunwei 已提交
37 38 39 40
done
adb shell "echo  >>  $ANDROID_DIR/$RESULT_FILENAME"
done
adb pull $ANDROID_DIR/$RESULT_FILENAME .
41 42 43
echo "\n--------------------------------------"
cat $RESULT_FILENAME
echo "--------------------------------------"