Return to Snippet

Revision: 41338
at February 16, 2011 10:25 by mattsn0w


Initial Code
#!/bin/bash
# calculate the mean average of wall clock time from multiple /usr/bin/time results.
#

file=${1}
cnt=0

if [ ${#file} -lt 1 ]; then
    echo "you must specify a file containing output of /usr/bin/time results"
    exit 1
elif [ ${#file} -gt 1 ]; then
    samples=(`grep real ${file} | awk '{print $2}' | cut -dm -f2 | cut -ds -f1`)

    for sample in ${samples}; do
        cnt=$(echo ${cnt}+${sample} | bc -l)
    done
    # Calculate the 'Mean' average (sum / samples).
    mean_avg=$(echo ${cnt}/${#samples[@]} | bc -l)
    mean_avg=$(echo ${mean_avg} | cut -b0-5)

    printf "\tSamples:\t%s \n\tMean Avg:\t%s\n\n" ${#samples[@]} ${mean_avg}
fi

Initial URL

                                

Initial Description

                                

Initial Title
calculate mean average from /usr/bin/time results

Initial Tags

                                

Initial Language
Bash