0001
0002
0003
0004
0005 set -e
0006
0007
0008 perf stat -a true > /dev/null 2>&1 || exit 2
0009
0010
0011 perf stat -a -e cycles sleep 1 2>&1 | grep -e cpu_core && exit 2
0012
0013 test_global_aggr()
0014 {
0015 perf stat -a --no-big-num -e cycles,instructions sleep 1 2>&1 | \
0016 grep -e cycles -e instructions | \
0017 while read num evt hash ipc rest
0018 do
0019
0020 if [ "$num" = "<not" ]; then
0021 continue
0022 fi
0023
0024
0025 if [ "$evt" = "cycles" ]; then
0026 cyc=$num
0027 continue
0028 fi
0029
0030
0031 if [ -z "$cyc" ]; then
0032 continue
0033 fi
0034
0035
0036 res=`printf "%.2f" $(echo "scale=6; $num / $cyc" | bc -q)`
0037 if [ "$ipc" != "$res" ]; then
0038 echo "IPC is different: $res != $ipc ($num / $cyc)"
0039 exit 1
0040 fi
0041 done
0042 }
0043
0044 test_no_aggr()
0045 {
0046 perf stat -a -A --no-big-num -e cycles,instructions sleep 1 2>&1 | \
0047 grep ^CPU | \
0048 while read cpu num evt hash ipc rest
0049 do
0050
0051 if [ "$num" = "<not" ]; then
0052 continue
0053 fi
0054
0055
0056 if [ "$evt" = "cycles" ]; then
0057 results="$results $cpu:$num"
0058 continue
0059 fi
0060
0061 cyc=${results
0062 cyc=${cyc%% *}
0063
0064
0065 if [ -z "$cyc" ]; then
0066 continue
0067 fi
0068
0069
0070 res=`printf "%.2f" $(echo "scale=6; $num / $cyc" | bc -q)`
0071 if [ "$ipc" != "$res" ]; then
0072 echo "IPC is different for $cpu: $res != $ipc ($num / $cyc)"
0073 exit 1
0074 fi
0075 done
0076 }
0077
0078 test_global_aggr
0079 test_no_aggr
0080
0081 exit 0