Snippets

Tony Ho CPU_BenchMark_Scripts

Created by Tony Ho last modified
#! /bin/bash

# para1: gerp string
# para2: log file name
# para3: field separator
function common_average(){
    GREP_PATTERN=$1
    RESULT_FILE=$2
    FIELD_SEPARATOR=$3

    #echo RESULT_FILE        ="$RESULT_FILE"
    #echo GREP_PATTERN       ="$GREP_PATTERN"
    #echo FIELD_SEPARATOR    ="$FIELD_SEPARATOR"

    if [ ! -e ${RESULT_FILE} ]; then
        echo "File [$RESULT_FILE] not exist!!"
        exit -1
    fi
    grep "$GREP_PATTERN"  $RESULT_FILE > $RESULT_FILE_$$.log

    echo -n $1
    #awk -F"$3" 'BEGIN{sum=0;num=0}  {sum+=$2;num+=1;}  END{printf "sum = %f,average = %f\n",sum,sum/num}' $RESULT_FILE_$$.log
    awk -F"$3" 'BEGIN{sum=0;num=0}  {sum+=$2;num+=1;}  END{printf " = %f\n",sum/num}' $RESULT_FILE_$$.log

    rm $RESULT_FILE_$$.log
}

echo ===========CoreMark================================
# Cormark
common_average 'Iterations/Sec'     coremark.log    ':'
# dhry2
echo ===========Dhry2===================================
common_average 'VAX  MIPS rating'   dhry2.log       '='
# L1 latency 
echo ===========L1 Lat==================================
common_average '0.00098'            lat_mem_rd.log  ' ' 
# L2 latency 
echo ===========L2 Lat==================================
common_average '0.12500'            lat_mem_rd.log  ' '

echo ===========integer=================================
common_average  'integer bit'       lat_ops.log     ':'
common_average  'integer add'       lat_ops.log     ':'
common_average  'integer mul'       lat_ops.log     ':'
common_average  'integer div'       lat_ops.log     ':'
common_average  'integer mod'       lat_ops.log     ':'
echo ===========int64==================================
common_average 'int64 bit'          lat_ops.log     ':'
common_average 'uint64 add'         lat_ops.log     ':'
common_average 'int64 mul'          lat_ops.log     ':'
common_average 'int64 div'          lat_ops.log     ':'
common_average 'int64 mod'          lat_ops.log     ':'
echo ===========float==================================
common_average 'float add'          lat_ops.log     ':'
common_average 'float mul'          lat_ops.log     ':'
common_average 'float div'          lat_ops.log     ':'
echo ===========double=================================
common_average 'double add'         lat_ops.log     ':'
common_average 'double mul'         lat_ops.log     ':'
common_average 'double div'         lat_ops.log     ':'
echo ===========float/double bogo======================
common_average 'float bogomflops'   lat_ops.log     ':'
common_average 'double bogomflops'  lat_ops.log     ':'

exit 0
#! /bin/sh

PWD_DIR=$PWD

################################################################################
#Function: run the program for specified times
#Para1: test program path
#Para2: command to be run
#Para3: test program output log
#Para4: repeat run times
################################################################################
function runTest(){
    #cd $1
    #export PWD=
    ## ToDo: judge whether the bash/mksh is exist, use the $4 to set repeat times
    #if[-z which bash];then
    #    for ((i=0; i<$4; i++)); do
    #        echo abc
    #    done
    #else
    #fi
    pwd
    echo PARA1=$1
    echo PARA2=$2
    echo PARA3=$3
    for i in 1 2 3 4 5 6 7 8 9 10;do
        eval "$2" 2>&1 | tee -a $3
    done

    #cp $PWD_DIR/$1/$3 $PWD_DIR/
    #cd $PWD_DIR
}

#Para1: test program path                   #Para2: command to be run   #Para3: test program output log #Para4: repeat run times
#runTest classic_benchmarks/source_code      'echo 0x30 |./dhry2'        dhry2.log           10
#runTest classic_benchmarks/source_code      './dhry2'        dhry2.log           10
#runTest classic_benchmarks/source_code      'echo | ./dhry2'        dhry2.log           10
#runTest lmbench/bin/arm-linux              './lat_ops'                  lat_ops.log
#runTest lmbench/bin/arm-linux              './lat_mem_rd 1M'                lat_mem_rd.log
#runTest coremark_v1.0                      'time ./coremark.exe   0x0 0x0 0x66 200000 7 1 2000'                  coremark.log 

runTest coremark_v1.0                      'time ./coremark.exe   0x0 0x0 0x66 200000 7 1 2000'                  coremark.log 
runTest classic_benchmarks/source_code      'echo | ./dhry2'        dhry2.log           10
runTest lmbench/bin/arm-linux              './lat_ops'                  lat_ops.log
runTest lmbench/bin/arm-linux              './lat_mem_rd 1M'                lat_mem_rd.log

exit 0

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.