You are here:home»Entries in English»Linux stuff»Bash scripting – I think I earned 5 stars… Well, 4.5.

Bash scripting – I think I earned 5 stars… Well, 4.5.

On 25/01/2011, in Entries in English, Linux stuff, by admin

if [ -e $compare_table_file ]; then
        echo “Compare table found, comparing results”
        ### TODO, create two dimensional array from report and static table”
        ### Compare the tables
        threshold=5 ### if more than 5% less than const, the test would FAIL
        frames_tested=( `cat $report_name | grep -A 50 “Throughput and Latency results” | grep -A 30 “Frame” | grep -G “[0-9]”| grep -v “Run” | awk {‘print $1″ “$3’}` )
        frames_compared_to=( `cat $compare_table_file | sed ‘s/\”//’ | grep -A 30 “Frame” | grep -G “[0-9]”| grep -v “Run” | awk {‘print $1″ “$3’}` )

        let test_frames_tested=${#frames_tested[*]}/2
        let test_frames_comprated=${#frames_compared_to[*]}/2

        if [ $test_frames_tested -eq 1 ]; then
                echo “wrong count of frames and results”
                reportSuccess=”FAIL”
                return
        fi

        if [ $test_frames_comprated -eq 1 ]; then
                echo “wrong count of frames and consts”
                reportSuccess=”FAIL”
                return
        fi

        ## Ugly solution to solve the bad output

        let runtime1=${#frames_tested[*]}-1
        let runtime2=${#frames_compared_to[*]}-1

        echo -e “====\t ==========\t ========\t ========”
        echo -e “Size\t Throughput\t Constant\t Variance”
        echo -e “====\t ==========\t ========\t ========”
        #for i in `seq 0 2 ${#frames_tested[*]}`; do
        for i in `seq 0 2 $runtime1`; do
        #for b in `seq 0 2 ${#frames_compared_to[*]}`; do
                for b in `seq 0 2 $runtime2`; do
                if [ “${frames_tested[$i]}” == “${frames_compared_to[$b]}” ]; then
                calc=$(echo “scale=2; -1 * (100 – (100 * ${frames_tested[$i+1]} / ${frames_compared_to[$b+1]}))” | bc)
                rounded=$(echo “scale=0; -1 * (100 – (100 * ${frames_tested[$i+1]} / ${frames_compared_to[$b+1]}))” | bc)
                echo -e “${frames_tested[$i]}\t ${frames_tested[$i+1]}%\t ${frames_compared_to[$b+1]}%\t $calc%”
                        abs_rounded=${rounded#-}
                        if [ $abs_rounded -le $threshold ]; then
                                reportSuccess=”SUCCESS”
                        else
                                reportSuccess=”FAIL”
                                fail=1
                        fi
                fi
                done
        done

        if [ “$fail” == “1” ]; then
                reportSuccess=”FAIL”
        else
                reportSuccess=”SUCCESS”
        fi
else
        return
fi

dmelody – bringing melody to digital perspective
about author

admin

Just a cool user :)

 

Leave a Reply

Your email address will not be published.

ERROR: si-captcha.php plugin: GD image support not detected in PHP!

Contact your web host and ask them to enable GD image support for PHP.

ERROR: si-captcha.php plugin: imagepng function not detected in PHP!

Contact your web host and ask them to enable imagepng for PHP.