Home | History | Annotate | Download | only in tests
      1 #!/bin/sh
      2 
      3 # temporary files used by this script
      4 my_perf=/tmp/.perf.$$
      5 my_perf_pattern=/tmp/.perf.*
      6 
      7 # commands to measure certain metrics
      8 cmd_VCrate="Video+Capture+Rate CAMT PERF.awk+who=CAMT+from=Hardware+what=frame+how=received"
      9 cmd_VDrate="Video+Decode+Rate VD_T PERF.awk+who=VD_T+to=HLMM+what=frame+how=sending"
     10 cmd_VDTrate="Video+Decode+Rate VD_T PERF.awk+who=VD_T+to=LLMM+what=frame+how=sending"
     11 cmd_VErate="Video+Encode+Rate VE_T PERF.awk+who=VE_T+to=HLMM+what=buffer+how=sending"
     12 cmd_VERrate="Video+Encode+Input+Rate VE__ PERF.awk+who=VE__+from=HLMM+what=frame+how=received"
     13 cmd_VPPYrate="Video+PreProc+YUV+Output+Rate VPPT PERF.awk+who=VPPT+to=HLMM+what=frame+how=sending"
     14 cmd_VPPRrate="Video+PreProc+RGB+Output+Rate VPPT PERF.awk+who=VPPT+to=HLMM+what=frame+how=sending"
     15 cmd_VPPIrate="Video+PreProc+Input+Rate VPP_ PERF.awk+who=VPP_+from=HLMM+what=frame+how=received"
     16 cmd_VPrate="Video+Display+Rate VP_T PERF.awk+who=VP_T+to=Hardware+what=frame+how=sending"
     17 cmd_VCPrate="Video+Preview+Rate VP_T PERF.awk+who=VP_T+to=Hardware+what=frame+how=sending"
     18 
     19 # save the original test command
     20 test="$@"
     21 
     22 # --------- BEGIN DEBUG INFRASTRUCTURE ---------
     23 VFLAG=;DBG=false;DO=;DODO=;PERFORM=
     24 debug_do() { perform=$PERFORM; if [ "$1" = "-y" ]; then shift; perform=; fi
     25 [ "$1" = "eval" ] && echo $2 || echo $*; $perform $*
     26 }
     27 debug_on() { VFLAG=$1;DBG=$2;DO=debug_do;DODO=debug_do;PERFORM=$3
     28 }
     29 
     30 # ---------- END DEBUG INFRASTRUCTURE ----------
     31 # debug_on
     32 
     33 # ------------------------------ START FUNCTIONS ------------------------------
     34 # scale factor size => scale a size by factor percent
     35 scale() {
     36   if [ $1 -lt 100 ]
     37   then
     38     expr $2 / 2
     39   elif [ $1 -gt 100 ]
     40   then
     41     expr $2 \* 2
     42   else
     43     expr $2
     44   fi
     45 }
     46 
     47 warn_param() {
     48   echo "perf: Unsupported configuration of test: $1. No PERF measurement will be performed." 1>&2
     49 }
     50 
     51 # ------------------------------- END FUNCTIONS -------------------------------
     52 
     53 MSG=;EVAL=
     54 # figure out which test we are running, and add metrics to evaluate
     55 while true
     56 do
     57   # remove path
     58   i=`echo $1 | sed "s/.*\///"`
     59   case $i in
     60     # skip any test wrappers, such as armtime or time, as they are not the real
     61     # test being executed
     62     armtime) # we are measuring ARM time, we need to skip this and its options
     63       shift
     64 
     65       while true
     66       do
     67         case $1 in
     68           -v|-vv|-notime|-CPU=*) shift ;;  # skip options
     69           *)                     break ;;
     70         esac
     71       done
     72       ;;
     73 
     74     time)
     75       shift
     76 
     77       while true
     78       do
     79         case $1 in
     80           -*) shift ;;  # skip options
     81           *)  break ;;
     82         esac
     83       done
     84       ;;
     85 
     86     # this is the test then - see if we recognize it
     87     
     88     AvPlayTest*)
     89       case $2 in
     90         6)     VDsize=$(expr $6 \* $7 \* 2)
     91                VPsize=$(scale $18 $(scale $19 $VDsize)) ;;               
     92         13|14) VDsize=$(expr $9 \* $10 \* 2)
     93                VPsize=$(scale $16 $(scale $17 $VDsize)) ;;
     94         15)    VDsize=$(expr $5 \* $6 \* 2)
     95                VPsize=$(scale $12 $(scale $13 $VDsize)) ;;
     96         *)     warn_param $1 ; break ;;
     97       esac
     98       EVAL="$EVAL $cmd_VDTrate+size=$VDsize"
     99       EVAL="$EVAL $cmd_VPrate+size=$VDsize"
    100       break
    101       ;;
    102 
    103     AVRecordTest*)
    104       size=$(expr $4 \* $5 \* 2)
    105       EVAL="$EVAL $cmd_VCrate+size=$size"
    106       EVAL="$EVAL $cmd_VCPrate+size=$size"
    107       break
    108       ;;
    109 
    110     CameraTest*)
    111       width=176;height=144
    112       shift
    113 
    114       while [ $# -gt 0 ]
    115       do
    116         case $1 in
    117           -w)   width=$2; shift ;;
    118           -w*)  width=`echo $1 | cut -c3-` ;;
    119           -h)   height=$2; shift ;;
    120           -h*)  height=`echo $1 | cut -c3-` ;;
    121           --widthv*=*)  width=`echo $1 | cut -d= -f2` ;;
    122           --widthv*)    width=$2; shift ;;
    123           --heightv*=*) height=`echo $1 | cut -d= -f2` ;;
    124           --heightv*)   height=$2; shift ;;
    125           -a|--hel*|-d|--de*|-g|--u*|-j|--n*|-u|--ti*|-e|--di*|--*=*) ;;
    126           -*) shift ;;
    127           *) ;;
    128         esac
    129         shift
    130       done
    131 
    132       size=$(expr $width \* $height \* 2)
    133       EVAL="$EVAL $cmd_VCrate+size=$size"
    134       EVAL="$EVAL $cmd_VCPrate+size=$size"
    135 
    136       break
    137       ;;
    138 
    139     PostProcTest*)
    140       if [ \( $2 -eq 0 \) -o \( \( $2 -ge 8 \) -a \( $2 -le 15 \) \) ]
    141       then
    142         size=$(expr $4 \* $5 \* 2)
    143       else
    144         warn_param $1 ; break
    145       fi
    146 
    147       EVAL="$EVAL $cmd_VPrate+size=$size"
    148       break
    149       ;;
    150 
    151     VideoCaptureTest*)
    152       width=176;height=144
    153       shift
    154 
    155       while [ $# -gt 0 ]
    156       do
    157         case $1 in
    158           -w)   width=$2; shift ;;
    159           -w*)  width=`echo $1 | cut -c3-` ;;
    160           -h)   height=$2; shift ;;
    161           -h*)  height=`echo $1 | cut -c3-` ;;
    162           --widthv*=*)  width=`echo $1 | cut -d= -f2` ;;
    163           --widthv*)    width=$2; shift ;;
    164           --heightv*=*) height=`echo $1 | cut -d= -f2` ;;
    165           --heightv*)   height=$2; shift ;;
    166           -a|--hel*|-d|--debu*|-g|--u*|-j|--n*|-u|--ti*|-e|--di*|-D|--debl*|--*=*) ;;
    167           -*) shift ;;
    168           *) ;;
    169         esac
    170         shift
    171       done
    172 
    173       size=$(expr $width \* $height \* 2)
    174       EVAL="$EVAL $cmd_VCrate+size=$size"
    175       EVAL="$EVAL $cmd_VERrate"
    176       EVAL="$EVAL $cmd_VCPrate+size=$size"
    177 
    178       break
    179       ;;
    180 
    181     VidDecTest*)
    182       size=$(expr $6 \* $7 \* 2)
    183       EVAL="$EVAL $cmd_VDrate+size=$size"
    184       break
    185       ;;
    186 
    187     VideoDisplayTest*)
    188       case $2 in
    189         5|6) VDsize=$(expr $5 \* $6 \* 2)
    190              VPsize=$(scale $12 $(scale $13 $VDsize)) ;;
    191         *)   warn_param $1 ; break ;;
    192       esac
    193       EVAL="$EVAL $cmd_VDTrate+size=$VDsize"
    194       EVAL="$EVAL $cmd_VPrate+size=$VDsize"
    195       break
    196       ;;
    197 
    198     VideoEncTest*)
    199       size=$(expr $4 \* $5 \* 2)
    200       if [ $6 -eq 19 ]
    201       then
    202         size=$(expr $(expr $size \* 3) / 4)
    203       fi
    204       EVAL="$EVAL $cmd_VERrate+size=$size"
    205       EVAL="$EVAL $cmd_VErate"
    206       break
    207       ;;
    208 
    209     VPPCaptureTest*)
    210       VCsize=
    211       IPsize=
    212       VEsize=
    213       case $2 in        
    214         3|4|5) VCsize=$(expr $4 \* $5 \* 2)
    215                VEsize=$VCsize ;;
    216         1)     IPsize=$(expr $9 \* $10 \* 2) ;;
    217         *)     warn_param $1 ; break ;;
    218       esac
    219 
    220       [ "$VCsize" ] && EVAL="$EVAL $cmd_VCrate+size=$VCsize"
    221       # [ "$VEsize" ] && EVAL="$EVAL $cmd_VERrate+size=$size"
    222       [ "$VEsize" ] && EVAL="$EVAL $cmd_VErate"
    223       break
    224       ;;
    225 
    226     VPPTest*)
    227       in_size=$(expr $4 \* $5)
    228 
    229       case $6 in
    230         3)       in_size=$(expr $in_size \* 3) ;;
    231         1|2|4|5|6|7) in_size=$(expr $in_size \* 2) ;;  # 5, 6, 7 should not be here
    232         0|5)   in_size=$(expr $(expr $in_size \* 3) / 2) ;;
    233         6|8)     ;;
    234         7|9)     in_size=$(expr $in_size / 2) ;;
    235         10)      in_size=$(expr $in_size / 4) ;;
    236         11)      in_size=$(expr $in_size / 8) ;;
    237         *)  warn_param $1 ; break ;;
    238       esac
    239 
    240       out_size=$(expr $8 \* $9)
    241 
    242       case $10 in
    243         0)   yuv_size=0 ;;
    244         2|3) yuv_size=$(expr $out_size \* 2) ;;
    245         1|*) yuv_size=$(expr $(expr $out_size \* 3) / 2) ;;
    246       esac
    247 
    248       case $11 in
    249         0)   rgb_size=0 ;;
    250         4|6) rgb_size=$out_size ;;
    251         10)  rgb_size=$(expr $out_size * 4) ;;
    252         8)   rgb_size=$(expr $out_size / 4) ;;
    253         1)   rgb_size=$(expr $out_size \* 3) ;;
    254         3)   rgb_size=$(expr $(expr $out_size \* 3) / 2) ;;
    255         9)   rgb_size=$(expr $out_size / 8) ;;
    256         5|7) rgb_size=$(expr $out_size / 2) ;;
    257         2|*) rgb_size=$(expr $out_size \* 2) ;;
    258       esac
    259 
    260       if [ $yuv_size -eq $rgb_size ]
    261       then
    262         MSG="RGB and YUV output frame sizes are identical.  Printing multiples of the frame rates."
    263         factor=2x+
    264       fi
    265 
    266       EVAL="$EVAL $cmd_VPPIrate+size=$in_size"
    267       [ $rgb_size ] && EVAL="$EVAL $factor$cmd_VPPRrate+size=$rgb_size"
    268       [ $yuv_size ] && EVAL="$EVAL $factor$cmd_VPPYrate+size=$yuv_size"
    269       break
    270       ;;
    271 
    272     VPPTunnelTest*)
    273       IDsize=
    274       VDsize=
    275       VPsize=
    276       case $2 in
    277         7)     IDsize=$(expr $4 \* $5 \* 2)
    278                IVPsize=$IDsize
    279                if [ $# -gt 8 ]
    280                then
    281                  IVPsize=$(expr $8 \* $9 \* 2)
    282                fi
    283 
    284                case $6 in
    285                1) 2 ;; # overwrite
    286                1) 4 ;;
    287                2) 3 ;;
    288                2|3|5|6) 2 ;;
    289                4) 1.5 ;;
    290                5|7) 1 ;;
    291                6|8) 0.5 ;;
    292                9) 0.25 ;;
    293                10) 0.125 ;;
    294                esac
    295 
    296                warn_param $1 ; break
    297                ;;
    298         1)     VPsize=$(expr $8 \* $9 \* 2) ;;
    299         10|12) VDsize=$(expr $5 \* $6 \* 2)
    300                VPsize=$(expr $10 \* $11 \* 2) ;;
    301         *)   warn_param $1 ; break ;;
    302       esac
    303       [ "$VDsize" ] && EVAL="$EVAL $cmd_VDTrate+size=$VDsize"
    304       [ "$VPsize" ] && EVAL="$EVAL $cmd_VPrate+size=$VPsize"
    305       break
    306       ;;
    307 
    308     *)
    309       echo "perf: Unsupported test: $1. No PERF measurement will be performed." 1>&2
    310       break
    311       ;;
    312   esac
    313 done
    314 
    315 # If we need to evaluate some PERF metrics, set up PERF measurement
    316 if [ "$EVAL" ]
    317 then
    318   echo "trace_file=$my_perf
    319   csv=1
    320   mask=0x3cffff" > ./perf.ini
    321   rm $my_perf_pattern*.trace
    322 else
    323   echo csv=1 > ./perf.ini
    324 fi
    325 
    326 # run the test
    327 $test
    328 
    329 # evaluate the test
    330 evaluate_test() {
    331   if [ "$MSG" ]
    332   then
    333     echo perf: NOTE: $MSG
    334   fi
    335 
    336   while [ $# -gt 1 ]
    337   do
    338     echo Evaluating `echo $1 | sed "s/\+/ /g"` ...
    339     $DBG echo /omx/PERF_reader $my_perf*$2.trace "|" awk -f /omx/`echo $3 | sed "s/\+/ /g"`
    340     /omx/PERF_reader $my_perf*$2.trace | awk -f /omx/`echo $3 | sed "s/\+/ /g"`
    341     shift 3
    342   done
    343   echo csv=1 > ./perf.ini
    344 }
    345 evaluate_test $EVAL
    346 
    347